
<!DOCTYPE html>
<html>
<head>

<meta charset="UTF-8">
		<title>企业员工团购</title>
<link rel="stylesheet" type="text/css"	href="https://fx.sh.189.cn/nxtmall/static/template/default/main.css?v=2">
<link rel="stylesheet" type="text/css"	href="https://fx.sh.189.cn/nxtmall/static/template/default/fillOrder/css/fillOrder.css?v=13">
<link rel="stylesheet" type="text/css"	href="https://fx.sh.189.cn/nxtmall/static/common/datePicker/css/datePicker.css?v=1">
<link rel="stylesheet" type="text/css"	href="https://fx.sh.189.cn/nxtmall/static/common/css/animate.css">
<link rel="stylesheet" type="text/css"  href="https://fx.sh.189.cn/nxtmall/static/common/font/iconfont.css?v=1">
<link rel="stylesheet" type="text/css" href="https://fx.sh.189.cn/nxtmall/static/common/swiper-4.4.6/css/swiper.css">
<script type="text/javascript" src="https://fx.sh.189.cn/nxtmall/static/common/js/flexible_css.js"></script>
<script type="text/javascript" src="https://fx.sh.189.cn/nxtmall/static/common/js/flexible.js"></script>
<style>
	[v-cloak]{
		display:none;
	}
	
	html{
		background-color:#E9EEF1;
	}
	
		:root{
			--mainColor:#FF9800;
		}
	
	
		.panel-title{
			color:;
			text-align:left;
		}
	
	.fade-enter-active, .fade-leave-active {
	  transition: all .2s;
	}
	.fade-enter, .fade-leave-to /* .fade-leave-active below version 2.1.8 */ {
	  opacity: 0.2;
	  height:0;
	}
	
	.layui-m-layershade{
	    background-color: rgba(33,33,33,.33)!important;
	}
	.layui-m-layer2 .layui-m-layercont i{
		width:15px !important;
		height:15px !important;
	}
	
</style>
<script type="text/javascript" src="https://fx.sh.189.cn/nxtmall/static/common/js/exif.js"></script>
<script type="text/javascript" src="https://fx.sh.189.cn/nxtmall/static/common/js/moment.min.js"></script>
<script type="text/javascript" src="https://fx.sh.189.cn/nxtmall/static/common/js/canvas_toblob_polyfill.js"></script>
<script type="text/javascript" src="https://fx.sh.189.cn/nxtmall/static/common/js/common.js?v=12"></script>
<script type="text/javascript" src="https://fx.sh.189.cn/nxtmall/static/common/js/jquery.min.js"></script>


<script type="text/javascript">
	// String endsWith Polyfill
	if (!String.prototype.endsWith) {
		String.prototype.endsWith = function(search, this_len) {
			if (this_len === undefined || this_len > this.length) {
				this_len = this.length;
			}
			return this.substring(this_len - search.length, this_len) === search;
		};
	}
	
	$.ajaxSetup({
		beforeSend:function(xhr,options){

			if(options.url && options.url.endsWith('/order/saveOrder')){
				xhr.setRequestHeader('SALEGOODSURL',window.location.href);
			}
			//获取销售品协议时，增加BUSINESSTYPE头
			if(options.url && options.url.endsWith('/product/getOfferAgreement')){
				xhr.setRequestHeader('BUSINESSTYPE','300');
				xhr.setRequestHeader('PRODUCTID','103857');
			}
		}
	});
	
</script>


<!-- 国双统计 -->
<script type='text/javascript'>

	function filterUrlParams(url) {
		if(!url){
			return url;
		}
		var qpos = url.indexOf('?');
		if(qpos===-1){
			return url;
		}
		var urlStr = url.substr(0,qpos);  
		var paramStr = url.substr(qpos+1);
	    var arr = new Array();
	    if (paramStr) {
	        var urlParamArr = paramStr.split("&"); 
	        for (var i = 0; i < urlParamArr.length; i++) {
	            var paramArr = urlParamArr[i].split("="); 
	            if (paramArr[0] === 'ticket' || paramArr[0]==='serial') {
	            	continue;
	            }
                arr.push(urlParamArr[i]);
	        }
	    }
	    if (arr.length > 0) {
	    	urlStr = urlStr + "?" + arr.join("&");
	    }
	    
	    return urlStr;
	}


	var _gsq = _gsq || [];
	var _GWD_CODE_ = 'GWD-002698';
	(function () {
	    var s = document.createElement('script');
	    s.type = 'text/javascript';
	    s.async = true;
	    s.src = (location.protocol == 'https:' ? 'https://ssl.' : 'http://static.') + 'gridsumdissector.com/js/Clients/GWD-002698-B8365B/gs.js';
	    var firstScript = document.getElementsByTagName('script')[0];
	    firstScript.parentNode.insertBefore(s, firstScript);
	})();
	
    function callGSEvent(businessType,title,field){
	   console.log(businessType,title,field);
	   _gsq.push(["T",_GWD_CODE_,"trackEvent",businessType,title,field]);
    }
    
    var _leadsId = "";
	$.post('/nxtmall/order/getOrderNo',{},
		function(result){
			if(result.status==='success'){
				_leadsId = result.data;
			}
		}		
	).error(function(err){
		console.log(err)
	})
    
    
    function pushGSStep1(info){
		var leadsId = _leadsId;
    	//return;
    	console.log('调用国双快照插码step1,leadsId=' + leadsId,info);
    	var stepCode = 'step1-' + leadsId;
    	_gsq.push([_GWD_CODE_,'addOrder',stepCode,info.amount]);	//订单总价
    	_gsq.push([_GWD_CODE_, 'setEcomProperty', stepCode, '1', leadsId]);
    	_gsq.push([_GWD_CODE_, 'setEcomProperty', stepCode, '2', '商品类别-' + info.businessType || '']); //商品类别
    	_gsq.push([_GWD_CODE_, 'setEcomProperty', stepCode, '3', '商品名称-' + info.productName || '']);  //商品名称	
    	_gsq.push([_GWD_CODE_, 'setEcomProperty', stepCode, '4', '商品url-' + filterUrlParams(info.url || window.location.href)]); //商品链接,如果没有传就取当前链接
    	_gsq.push([_GWD_CODE_, 'setEcomProperty', stepCode, '5', '付费方式-' + info.paymentMode || '']);	//付费方式
    	_gsq.push([_GWD_CODE_, 'setEcomProperty', stepCode, '6', '购买方式-' + info.buyMode || '']);		//购买方式
    	_gsq.push([_GWD_CODE_, 'setEcomProperty', stepCode, '7', '套餐金额-￥' + info.amount/100 || '']);		//套餐金额
    	_gsq.push([_GWD_CODE_, 'trackECom']);
    }
    
    function pushGSStep2(info,offers){
    	// Step2 先不传
    	return;
    	var leadsId = _leadsId;
    	console.log('调用国双快照插码step2,leadsId=' + leadsId,info,offers);
    	var stepCode = 'step2-' + leadsId;
    	_gsq.push([_GWD_CODE_,'addOrder',stepCode,info.amount]);	//订单总价
    	_gsq.push([_GWD_CODE_, 'setEcomProperty', stepCode, '1', leadsId]);
    	_gsq.push([_GWD_CODE_, 'setEcomProperty', stepCode, '2', filterUrlParams(info.url || window.location.href)]);	//商品URL
    	_gsq.push([_GWD_CODE_, 'setEcomProperty', stepCode, '3', info.productName || '']);		//商品名称
    	_gsq.push([_GWD_CODE_, 'setEcomProperty', stepCode, '4', info.customerName || '']);		//用户姓名
    	_gsq.push([_GWD_CODE_, 'setEcomProperty', stepCode, '5', info.customerIdCard || '']);		//身份证号
    	_gsq.push([_GWD_CODE_, 'setEcomProperty', stepCode, '6', info.contactPhone || '']);		//联系电话
    	_gsq.push([_GWD_CODE_, 'setEcomProperty', stepCode, '7', info.number || '']);		//选择号码
    	_gsq.push([_GWD_CODE_, 'setEcomProperty', stepCode, '8', info.address || '']);		//发货地址
    	_gsq.push([_GWD_CODE_, 'setEcomProperty', stepCode, '9', info.remark || '']);			//备注
    	
    	if(offers && offers.length>0){
    		var offerObj1 = null;
    		var offerObj2 = null;
    		var count = 1;
    		for(var i=0;i<offers.length;i++){
    			if(offers[i].type=='40'){
	    			if(count<=10){
						if(null == offerObj1){
							offerObj1 = {};
						}    				
	    				offerObj1[count] = offers[i].offerName;
	    			}else{
	    				if(null == offerObj2){
	    					offerObj2 = {};
	    				}
	    				offerObj2[count] = offers[i].offerName;
	    			}
	    			count++;
    			}
    		}
    		if(null!=offerObj1){
		    	_gsq.push([_GWD_CODE_, "addProduct", stepCode, "step2", "extra_step2.1", 1, 1, "", offerObj1]);
    		}
    		if(null!=offerObj2){
		    	_gsq.push([_GWD_CODE_, "addProduct", stepCode, "step2", "extra_step2.2", 1, 1, "", offerObj2]);
    		}
    	}
    	_gsq.push([_GWD_CODE_, 'trackECom']);
    }
    
    //订单提交时调用
    function pushGSStep3(info,protocols){
    	//Step3 先不传
    	return;
    	var leadsId = _leadsId;
    	console.log('调用国双快照插码step3,leadsId=' + leadsId,info,protocols);
    	var stepCode = 'step3-' + leadsId;
    	_gsq.push([_GWD_CODE_,'addOrder',stepCode,info.amount]);	//订单总价
    	_gsq.push([_GWD_CODE_, 'setEcomProperty', stepCode, '1', leadsId]);
    	_gsq.push([_GWD_CODE_, 'setEcomProperty', stepCode, '2', info.productName || '']);	//套餐名称
    	_gsq.push([_GWD_CODE_, 'setEcomProperty', stepCode, '3', info.number || '']);		//手机号1
    	_gsq.push([_GWD_CODE_, 'setEcomProperty', stepCode, '4', info.subNumber1 || '']);		//手机号2
    	_gsq.push([_GWD_CODE_, 'setEcomProperty', stepCode, '5', info.subNumber2 || '']);		//手机号3
    	_gsq.push([_GWD_CODE_, 'setEcomProperty', stepCode, '6', info.phone || '']);		//固话
    	_gsq.push([_GWD_CODE_, 'setEcomProperty', stepCode, '7', info.kdNumber || '']);		//宽带
    	_gsq.push([_GWD_CODE_, 'setEcomProperty', stepCode, '8', info.installAddress || '']);	//安装地址
    	_gsq.push([_GWD_CODE_, 'setEcomProperty', stepCode, '9', info.customerName || '']);		//姓名
    	_gsq.push([_GWD_CODE_, 'setEcomProperty', stepCode, '10', info.contactPhone || '']);	//联系电话
    	
    	//agreementUrl:"https://sh.189.cn/pdf/ywfwxy.pdf",
    	//agreemrntName:"业务服务协议"
    	if(protocols && protocols.length>0){
    		var proObj = {};
    		//var last = protocols.length<6?protocols.length:5;
    		for(var i=0;i<5;i++){
    			var pro = {
   					agreemrntName : '-',
   					agreementUrl:'-'
    			};
    			if(i<protocols.length){
    				pro = protocols[i];
    			}
    			proObj[i+1] = pro.agreemrntName;
    			proObj[i+6] = pro.agreementUrl;
    		}
	    	_gsq.push([_GWD_CODE_, "addProduct", stepCode, "step3", "extra_step3.1", 1, 1, "", proObj]);
	    	if(protocols.length>5){
	    		proObj = {};
	    		for(var i=0;i<5;i++){
	    			var pro = {
	   					agreemrntName : '-',
	   					agreementUrl:'-'
	    			};
	    			if(i+5<protocols.length){
	    				pro = protocols[i];
	    			}
	    			proObj[i+1] = pro.agreemrntName;
	    			proObj[i+6] = pro.agreementUrl;
	    		}
	    		_gsq.push([_GWD_CODE_, "addProduct", stepCode, "step3", "extra_step3.2", 1, 1, "", proObj]);
	    	}
    	}
    	_gsq.push([_GWD_CODE_, 'trackECom']);
    }
    
    //订单提交成功后调用
    function pushGSStep4(info){
    	//return;
    	var leadsId = _leadsId;
    	console.log('调用国双快照插码step4,leadsId=' + leadsId,info);
    	var stepCode = 'step4-' + leadsId;
    	_gsq.push([_GWD_CODE_,'addOrder',stepCode,info.amount]);
    	_gsq.push([_GWD_CODE_, 'setEcomProperty', stepCode, '1', leadsId]);
    	_gsq.push([_GWD_CODE_, 'setEcomProperty', stepCode, '2', info.backOrderNo || '']);	//后台订单号
    	_gsq.push([_GWD_CODE_, 'setEcomProperty', stepCode, '3', '订单时间-' + info.orderTime || '']);	//下单时间
    	_gsq.push([_GWD_CODE_, 'trackECom']);
    }
    
     
    
</script>
<!-- 国双统计结束 --></head>
<body style="overflow:auto;height:auto;">
	<div class="main-container" style="height:auto;overflow:hidden;" v-cloak>
		<div class="content" style="position:relative;z-index:10;">
<panel v-if="">
		<div>
			<div class="swiper-container">
				
				<!-- 注：优先使用 本地配置图片 -->
				   <div class="swiper-wrapper" >
				    </div>
	    		<!-- 如果需要分页器 -->
	    		<div class="swiper-pagination"></div>
			</div>
		</div>
	
	<!-- 查看商品详情 -->
 	<div align="center" v-if="saleImgs.length>0">
		<div style="padding:0.2rem 0;" v-if="showProductDetailImgs">
			<div class="h-flex-box tab-box" v-if="saleImgs.length>1">
				<template v-for="(img,index) in saleImgs">
					<div class="sales-detail-tab-li" :class="{'sale-seleceed':saleImg===img}" 
					@click="saleImg=img">
						{{img.name}}
					</div>
					<div v-if="index<saleImgs.length-1" class="tab-split"></div>
				</template>
			</div>
			<div  v-for="img in saleImg.imgs" :key="'img_' + new Date().getTime()">
				<img :src="img.src" style="width:100%;" v-if="!img.href"/>
				<a :href="img.href" target="_blank" rel="noopener noreferrer" v-else>
					<img :src="img.src" style="width:100%;"/>
				</a>
			</div>
		</div>
		<div style="height:0.5rem;line-height:0.5rem;">
			<span style="color:#ccc;font-size:0.37rem;" @click="showProductDetailImgs=!showProductDetailImgs;gsEvent('商品信息','查看商品详情');">
				<i class="iconfont" :class="[showProductDetailImgs?'icon-up':'icon-down']" style="font-size:0.37rem;"></i>&nbsp;
				{{showProductDetailImgs?'隐藏商品详情':'查看商品详情'}}
			</span>
		</div>
	</div>

</panel>

<panel title="选择付费周期" :sub-title="getPaymentPriceName(payment)" v-if="payments && payments.length>1">
	<ul class="ul-package">
		<li class="li-package" v-for="pc in payments" 
			@click="selectPayment(pc);gsEvent('套餐信息','用户选择付费周期【' + pc.paymentCycle + '】');"
			:class="{'selected':payment===pc}">
			{{pc.paymentCycle}}
		</li>
		<li class="li-package-empty"></li>
		<li class="li-package-empty"></li>
	</ul>
</panel>


<template v-for="mainOffer in mainOffers">
	<panel :title="mainOffer.mainOfferName" v-if="mainOffer.isSelect !==undefined && mainOffer.isSelect != 1">
		<ul class="ul-package">
			<li class="li-package" 
				@click="mainOffer.selected=false;gsEvent('套餐信息',mainOffer.mainOfferName + '【不需要】');"
				:class="{'selected':!mainOffer.selected}">
				不需要
			</li>
			<li class="li-package" 
				@click="mainOffer.selected=true;gsEvent('套餐信息',mainOffer.mainOfferName + '【需要】');"
				:class="{'selected':mainOffer.selected}">
				需要
			</li>
			<li class="li-package-empty"></li>
		</ul>
	</panel>
</template>

<template>
	<panel :title="offerGroup.groupName" v-for="offerGroup in offerGroups" :ref="'group' + offerGroup.groupCode">
		<template v-if="!offerGroup.selectAll">
			<div v-for="(sg,index) in offerGroup.subGroups" >
 				<div class="li-optional-pkg h-flex-box" v-for="offer in sg.showOffers" style="align-items:center;"
					@click="clickGroupOffer(offer,offerGroup,sg);gsEvent('套餐信息',(offer.selected?'选择':'取消选择') + '【' + offer.offerName + '】');"
					:class="{'selected':offer.selected}" align="center">
					<div style="width:0.5rem;" align="center">
						<div class="check-mark" v-show="offer.selected"></div>
					</div>
					<div style="flex:1;text-overflow:ellipsis;white-space:normal;" align="left">
						{{offer.offerAliasName?offer.offerAliasName:offer.offerName}}
					</div>
					<template v-if="offer.selected && offer.maxNum>1">
						<img src="https://fx.sh.189.cn/nxtmall/static/common/images/sub.png" style="height:0.3rem;" 
							@click.stop="changeOfferNum(offer,-1);gsEvent('套餐信息', '修改可选包【' + offer.offerName + '】数量,修改为' + offer.num);" />
						<div style="width:1rem;font-size:0.32rem;">x{{offer.num}}</div>
						<img src="https://fx.sh.189.cn/nxtmall/static/common/images/plus.png" style="height:0.3rem;" 
							@click.stop="changeOfferNum(offer,1);gsEvent('套餐信息', '修改可选包【' + offer.offerName + '】数量,修改为' + offer.num);" />
					</template>
				</div>
				<hr v-if="index<offerGroup.subGroups.length-1">
			</div>
		</template>
		<template v-else>
			<ul class="ul-package" :ref="'group' + offerGroup.groupCode">
				<li class="li-package" 
					@click="clickGroupOffer(0,offerGroup);gsEvent('套餐信息',offerGroup.groupName + '【不需要】');"
					:class="{'selected':offerGroup.selectCount === 0}">
					不需要
				</li>
				<li class="li-package" 
					@click="clickGroupOffer(1,offerGroup);gsEvent('套餐信息',offerGroup.groupName + '【需要】');"
					:class="{'selected':offerGroup.selectCount > 0}">
					需要
				</li>
				<li class="li-package-empty"></li>
			</ul>
		</template>
	</panel>
</template>
<!-- 不在分组中的单独可选包 -->
<panel v-if="ungroupOffers.length>0">
	<div class="li-optional-pkg h-flex-box" v-for="offer in ungroupOffers" style="align-items:center;"
		@click="offer.selected=!offer.selected;gsEvent('套餐信息',(offer.selected?'选中':'取消选中') + '【' + offer.offerName + '】');"
		:class="{'selected':offer.selected}" align="center">
		<div style="width:0.5rem;" align="center">
			<div class="check-mark" v-show="offer.selected"></div>
		</div>
		<div style="flex:1" align="left">
			{{offer.offerAliasName?offer.offerAliasName:offer.offerName}}
		</div>
		<template v-if="offer.selected && offer.maxNum>1">
			<img src="https://fx.sh.189.cn/nxtmall/static/common/images/sub.png" style="height:0.3rem;" 
					@click.stop="changeOfferNum(offer,-1)" />
			<div style="width:1rem;font-size:0.32rem;">x{{offer.num}}</div>
			<img src="https://fx.sh.189.cn/nxtmall/static/common/images/plus.png" style="height:0.3rem;" 
				 @click.stop="changeOfferNum(offer,1)" />
		</template>
	</div>
</panel>



<panel title="用户信息">
	<div class="input-item">
			<div class="input-label">
				<span>用户姓名</span>
			</div>
		<div class="input-content">
			<input v-model.trim="orderInfo.customerName" maxlength="20" @click="inputClick(event);gsEvent('用户信息','输入用户姓名');" 
			:class="{'invalid-field':invalidField==='customerName'}"
					placeholder="请输入用户姓名" ref="customerName"/>
		</div>
	</div>
	<div class="input-item">
			<div class="input-label">
				<span>身份证号</span>
			</div>
		<div class="input-content">
			<input v-model.trim="orderInfo.customerIdCard" maxlength="18" @click="inputClick(event);gsEvent('用户信息','输入用户身份证');"
					placeholder="请输入身份证号" ref="customerIdCard"/>
		</div>
	</div>
	<div class="input-item">
			<div class="input-label">
				<span>联系电话</span>
			</div>
		<div class="input-content">
			<input v-model.trim="orderInfo.contactPhone" maxlength="11" @click="inputClick(event);gsEvent('用户信息','输入用户联系电话');"
					placeholder="请输入联系电话" ref="contactPhone"/>
		</div>
	</div>
</panel><panel title="上传证件">
	
	<!-- 注：针对政企个人户名3张照片（正面、反面、手持），v4校验 -->
	<div class="upload-box" v-if="orderInfo.customerType === '个人'">
		<!-- 身份证正面 ID_CARD_FRONT-->
			<div class="box-item" @click="selectImage($event,'idCardFront','idCardFront');gsEvent('上传照片','上传身份证正面照');">
				<img style="width: 100%;height:auto;" :src="images.idCardFront?images.idCardFront:'https://fx.sh.189.cn/nxtmall/static//common/images/upload_cert_front.png'" ref="idCardFront"
				:class="{'invalid-field':invalidField==='idCardFront'}">
				
				<div align="center" style="color:#B8B8B8;padding:0.1rem 0;font-size:0.33rem;">
					身份证正面（请实拍身份证原件）
				</div>
			</div>
		
		<!-- 身份证反面 ID_CARD_BACK-->
			<div class="box-item" @click="selectImage($event,'idCardBack','idCardBack');gsEvent('上传照片','上传身份证正反照');">
				<img style="width: 100%;height:auto;" :src="images.idCardBack?images.idCardBack:'https://fx.sh.189.cn/nxtmall/static//common/images/upload_cert_back.png'" ref="idCardBack"
				:class="{'invalid-field':invalidField==='idCardBack'}">
				
				<div align="center" style="color:#B8B8B8;padding:0.1rem 0;font-size:0.33rem;">
					身份证反面（请实拍身份证原件）
				</div>
			</div>
		
		<!-- 免冠照 FRONT_FACE-->
			<div class="box-item" @click="selectImage($event,'frontFace','frontFace');gsEvent('上传照片','上传免冠照');">
				<img style="width: 100%;height:auto;" :src="images.frontFace?images.frontFace:'https://fx.sh.189.cn/nxtmall/static//common/images/upload_face.png'" ref="frontFace"
				:class="{'invalid-field':invalidField==='frontFace'}">
				
				<div align="center" style="color:#B8B8B8;padding:0.1rem 0;font-size:0.33rem;">
					正面自拍照，头占2/3（请勿翻拍照片）
				</div>
			</div>
	</div>
	
	<!-- 注：针对政企本地企业 -->
	<div class="upload-box" v-else-if="orderInfo.customerType === '政企'">
		<!-- 经办人身份证正面 AGENT_ID_CARD_FRONT-->
		<!-- 经办人身份证反面 AGENT_ID_CARD_BACK-->
		<!-- 经办人免冠照 AGENT_FRONT_FACE-->
		<!-- 企业介绍信 INTRODUCTION-->
		<!-- 组织机构代码证 ORGANIZATION-->
		<!-- 营业执照 BUSINESS_LICENSE-->
		<!-- -->
		<!--证件类型为： 三证合一 ，需要上传以下这个证件  BUSINESS_LICENSE-->
	</div>
	
	<!-- 注：通用 -->
	<div class="upload-box" v-else>
	
		<!-- 员工工作证照片 EMP_CARD-->
		
		<!-- 身份证正面 ID_CARD_FRONT-->
			<div class="box-item" @click="selectImage($event,'idCardFront','idCardFront');gsEvent('上传照片','上传身份证正面照');">
				<img style="width: 100%;height:auto;" :src="images.idCardFront?images.idCardFront:'https://fx.sh.189.cn/nxtmall/static//common/images/upload_cert_front.png'" ref="idCardFront"
				:class="{'invalid-field':invalidField==='idCardFront'}">
				
				<div align="center" style="color:#B8B8B8;padding:0.1rem 0;font-size:0.33rem;">
					身份证正面（请实拍身份证原件）
				</div>
			</div>
		
		<!-- 身份证反面 ID_CARD_BACK-->
			<div class="box-item" @click="selectImage($event,'idCardBack','idCardBack');gsEvent('上传照片','上传身份证正反照');">
				<img style="width: 100%;height:auto;" :src="images.idCardBack?images.idCardBack:'https://fx.sh.189.cn/nxtmall/static//common/images/upload_cert_back.png'" ref="idCardBack"
				:class="{'invalid-field':invalidField==='idCardBack'}">
				
				<div align="center" style="color:#B8B8B8;padding:0.1rem 0;font-size:0.33rem;">
					身份证反面（请实拍身份证原件）
				</div>
			</div>
		
		<!-- 免冠照 FRONT_FACE-->
			<div class="box-item" @click="selectImage($event,'frontFace','frontFace');gsEvent('上传照片','上传免冠照');">
				<img style="width: 100%;height:auto;" :src="images.frontFace?images.frontFace:'https://fx.sh.189.cn/nxtmall/static//common/images/upload_face.png'" ref="frontFace"
				:class="{'invalid-field':invalidField==='frontFace'}">
				
				<div align="center" style="color:#B8B8B8;padding:0.1rem 0;font-size:0.33rem;">
					正面自拍照，头占2/3（请勿翻拍照片）
				</div>
			</div>
		
		<!-- 手持 HOLD_FRONT_FACE-->
		
		
		<!-- 经办人身份证正面 AGENT_ID_CARD_FRONT-->
		<!-- 经办人身份证反面 AGENT_ID_CARD_BACK-->
		<!-- 经办人免冠照 AGENT_FRONT_FACE-->
		
		<!-- 企业介绍信 INTRODUCTION-->
		<!-- 组织机构代码证 ORGANIZATION-->
	
		<!--证件类型为： 三证合一 ，需要上传以下这个证件  BUSINESS_LICENSE-->
	</div>
</panel>

<panel title="上传工作证" v-if="showOtherPanel!='false'">

		<div class="box-item" v-for="(item,index) in otherImages" v-if="otherImages.length > 0">
			<div style="width: 1rem;line-height: 1rem;position: absolute;top: 0;right: 0;text-align: center;" 
				v-if="otherImages.length>minOtherImage && index === otherImages.length-1"
				@click="delCurrentOtherImage(otherImages,item);gsEvent('上传照片','删除其他照片');">
				<i class="iconfont icon-close" style="font-size:0.8rem;color:#fd482c"></i>
			</div>
			<img style="width: 100%;height:auto;" :src="images[item.name]?images[item.name]:'https://fx.sh.189.cn/nxtmall/static//common/images/upload_otherImage.png'" :ref="item.name"
			:class="{'invalid-field':invalidField===item.name}" @click="selectImage($event,item.name,item.name);gsEvent('上传照片','上传其他照片');">
			
			<div align="center" style="color:#B8B8B8;padding:0.1rem 0;font-size:0.33rem;">
				<span>{{item.tips}}</span>
			</div>
		</div>
		
		<div class="box-item" v-if="otherImages.length < maxOtherImage">
			<!-- <div class="panel-title">其他证件照</div> -->
			<div style="text-align: center;">
				<button @click="addOtherImage();gsEvent('上传照片','增加其他照片');" class="addOtherImage">添加</button>
			</div>
		</div>

</panel>
<panel title="选择号码" >
	<div class="input-item">
		<button class="button-number-select" :class="{'selected':orderInfo.number}" ref="number" v-if="autoNumberSelect">
			{{orderInfo.number?orderInfo.number:'暂无号码'}}
		</button>
		<button class="button-number-select" :class="{'selected':orderInfo.number}" ref="number" 
			@click="clickSelectNumberButton('main',currentSubNumberIndex);gsEvent('选择号码','打开选号界面')" v-else>
			{{orderInfo.number?orderInfo.number:'点击选择号码'}}
		</button>
	</div>
	<div class="number-dx" v-if="selectedNumber && (selectedNumber.prepay > 0 || selectedNumber.minAmount > 0)">
	
			<div v-if="selectedNumber.level < 3" style="width: 100%;background-color: #fff;
													    padding: 0.2rem 0.26rem;
													    margin-bottom: 0.2rem;
													    box-shadow: 0px 1px 0.1rem 0px #cacaca;
													    -webkit-box-shadow: 0px 1px 0.1rem 0px #cacaca;
													    font-weight: bold;
													    font-size: 0.45rem;
													    text-align: center;">
				<span v-if="selectedNumber.minAmount > 0">低消{{selectedNumber.minAmount}}元/月靓号</span> 
				<span v-if="selectedNumber.prepay > 0">免{{selectedNumber.prepay}}元预存</span>
			</div>
			
			<div class="number-tip" v-if="selectedNumber.minAmount > 0">
				<div style="margin-bottom: 0.15rem;font-size: 0.4rem;font-weight: bold;">1.靓号协议确认单文字</div>
				<div style="text-indent: 0.4rem;">
					您已订购  <span style="color: red;">{{ selectedNumber.minAmount }}</span> 元档次的靓号，
					订单完工后立即生效，本活动协议期为购首月及起{{ selectedNumber.level == 3?60:24 }}个月。
					协议期内，若客户办理过或改号需按照首次靓规则重新签订相关协议； 若退订本活动或离网，需支付提前退出本活动违约金，
					提前退出本活动违约金计算规则：剩余协议期为6个月（含）以下的，收取个月（含）以下的，收取 
					<span style="color: red;">{{ selectedNumber.minAmount }}</span>元；剩余协议期为6个月以上的，
					提前退出本活动违约金=剩余协议期月份/12（向上取整）*2* <span style="color: red;">{{ selectedNumber.minAmount }}</span>元。
					若客户退订本活动或离网时提前退出靓号所在套餐的，还需按照相应套餐营销规则支付提前退出套餐违约金。
				</div>
			</div>
			<div class="number-tip" v-if="selectedNumber.minAmount > 0">
				<div style="margin-bottom: 0.15rem;font-size: 0.4rem;font-weight: bold;">2.靓号协议确认单文字</div>
				<div style="text-indent: 0.4rem;">
					您的靓号每月承诺消费金额不低于 <span style="color: red;">{{ selectedNumber.minAmount }}</span>元，
					自业务完工后次月生效，协议期{{ selectedNumber.level == 3?60:24 }}个月，
					协议期内每月的实际消费金额（不含各类话费补贴及cp/sp费用）低于 <span style="color: red;">{{ selectedNumber.minAmount }}</span>元时，
					将按承诺消费金额 <span style="color: red;">{{ selectedNumber.minAmount }}</span>元/月收取。业务使用期间，若客户因欠费停机等原因，
					造成靓号所在套餐无法正常使用的，仍将按承诺消费金额 <span style="color: red;">{{ selectedNumber.minAmount }}</span>元/月收取。
				</div>
			</div>
			
			<!-- 预存 -->
			<div v-if="selectedNumber.prepay > 0 && selectedNumber.level >=3" class="number-tip">
				<div style="margin-bottom: 0.15rem;font-size: 0.4rem;font-weight: bold;">3.靓号预存确认单文字</div>
				<div style="text-indent: 0.4rem;">
					您选择的靓号需要预存<span style="color: red;">{{ selectedNumber.prepay }}</span>元，
					预存的<span style="color: red;">{{ selectedNumber.prepay }}</span>元话费自业务完工后一次性返还至您靓号的账户，
					不可抵扣CP/SP费用、不兑现、不转存。
				</div>
			</div>
		
		<div align="center" style="border-top:1px solid #eee;padding:0.3rem;" ref="agreeNumber">
			<input type="checkbox" id="agreeNumber" v-model="agreeNumber"/><label for="agreeNumber">&nbsp;我已阅读并同意该规则</label>
		</div>
	</div>
	
	<div class="popup-mask" id="popup-number-select" v-show="showNumberSelect" @touchmove.prevent 
		style="position:fixed;display: flex;align-items: center;">
		<div class="popup" @touchmove.prevent style="margin-top: 0;">
			<div class="popup-close">
				<i class="iconfont icon-close" @click="selectNumberCancel();gsEvent('选择号码','关闭选号界面')"></i>
			</div>
			<div class="popup-title">
				<div class="input-item">
					<div style="flex:3;">
						<input placeholder="输入号码搜索" type="number" v-model="queryNumberParams.numType" @click="inputClick(event);gsEvent('选择号码','输入选号条件')"/>
					</div>
					<div style="flex: 1.6;padding-left:0.3rem;">
						<button class="button-search-number" @click="numSearch();;gsEvent('选择号码','搜索号码')">搜索</button>
					</div>
				</div>
				<hr>
			</div>
			<ul class="number-list" v-if="numbers.length>0" style="padding: 0.2rem 0.2rem;">
				<li v-for="n in numbers" class="number-item-wrapper">
					<div class="number-item" @click="clickNumber(n);gsEvent('选择号码','选中号码【' + n.number + '】')"
					:class="{'selected':checkNumberUsed(n.number),'current':selectNumber && selectNumber.number===n.number}">
						<div>{{n.number}}</div>
						<div style="font-size: 0.28rem;">[预存{{n.prepay}}元 /低消{{n.minAmount==null?0:n.minAmount}}元]</div>
					</div>
				</li>
			</ul>
			<div class="number-empty" v-else>
				未查找到号码
			</div>
			<div class="h-flex-box" style="padding:0.1rem 0.8rem;">
				<div style="flex:1;padding:0.2rem 0.2rem;">
					<button class="button-change-page" @click="prevNumberPage();gsEvent('选择号码','翻到上一页号码【第' + queryNumberParams.page + '页】');" :disabled="queryNumberParams.page<=1">上一页</button>
				</div>
				<div class="number-page">第{{queryNumberParams.page}}页</div>
				<div style="flex:1;padding:0.2rem 0.2rem;">
					<button class="button-change-page" @click="nextNumberPage();gsEvent('选择号码','翻到下一页号码【第' + queryNumberParams.page + '页】');" :disabled="!hasNextNumberPage">下一页</button>
				</div>
			</div>
			<hr>
			
			<div class="h-flex-box">
				<div style="flex:1;padding:0.2rem 0.5rem;">
					<button class="button-select-number-cancel" @click="selectNumberCancel();gsEvent('选择号码','取消选号');">取消</button>
				</div>
				<div style="flex:1;padding:0.2rem 0.5rem;">
					<button class="button-select-number-ok" @click="selectNumberOk();gsEvent('选择号码','确定选号');">确定</button>
				</div>
			</div>
		</div>
	</div>
</panel>
<panel :title="'加装副卡（可以添加' + calcMaxSubNumberCount + '张副卡）'" v-if="calcMaxSubNumberCount>0">
	<panel v-for="(sn,index) in subNumbers">
		<div class="h-flex-box"  style="align-items: center;margin:0.2rem 0;">
			<div style="flex:1;">
				<button class="button-number-select" :class="{'selected':sn.number}" :ref="'subNumber'+index" @click="clickSelectNumberButton('sub',index)">
					{{sn.number?sn.number:'点击选号'}}
				</button>
			</div>
			<div style="color:var(--mainColor);padding:0 0.2rem;" @click="removeSubNumber(index)">
				<i class="iconfont icon-close" style="font-size:0.6rem!important;" ></i>
			</div>
		</div>
	</panel>
	<div align="center">
		<button class="li-package selected" v-if="subNumbers.length<calcMaxSubNumberCount" @click="addSubNumber" style="width:40%;">
			添加副卡
		</button>
	</div>
</panel>

<panel title="收货信息" v-if="showPanel">
	<!-- 判断是否有自提配置 -->
	
	<!-- 配送 start -->
	<template v-if="showAddress || orderInfo.deliveryMethod === '1' || orderInfo.deliveryMethod === 'AG'">
		<div class="h-flex-box">
			<div style="flex:1;">
				<div style="padding-right:0.1rem;">
			        <select class="info-select"  v-model="selectProvince"  ref="province" @change="gsEvent('配送信息','选择配送省【' + (selectProvince?selectProvince.name:'') + '】')">
						<option value="">
							选择省
		                </option>
						<option :value="p" v-for="p in allProvinces">
							{{p.name}}
		                </option>
		            </select>
				</div>
			</div>
			<div style="flex:1;">
				<div style="padding:0 0.05rem;">
			        <select class="info-select"  v-model="selectCity"  ref="city" @change="gsEvent('配送信息','选择配送市【' + (selectCity?selectCity.name:'') + '】')">
						<option value="">
							选择市
		                </option>
						<option :value="c" v-for="c in allCitys">
							{{c.name}}
		                </option>
		            </select>
				</div>
			</div>
			<div style="flex:1;">
				<div style="padding-left:0.1rem;">
			        <select class="info-select"  v-model="selectArea"  ref="area" @change="gsEvent('配送信息','选择配送区县【' + (selectArea?selectArea.name:'') + '】')">
						<option value="">
							选择区县
		                </option>
						<option :value="a" v-for="a in allAreas">
							{{a.name}}
		                </option>
		            </select>
				</div>
			</div>
		</div>
		<div class="input-item input-content">
			<input placeholder="上海市" ref="address"
				v-model.trim="address" @click="inputClick(event);gsEvent('配送信息','输入配送地址')">
		</div>
		<div class="input-item" v-if="false">
			<div class="input-label">
				<span>收货人姓名</span>
			</div>
			<div class="input-content">
				<input v-model.trim="orderInfo.contactName" maxlength="20" @click="inputClick"
						placeholder="请输入收货人姓名" ref="contactName"/>
			</div>
		</div>	
	</template>
	<!-- 配送 end -->
	
	<!-- 自提 start -->
	<template v-if="orderInfo.deliveryMethod === '2'">
		<div class="zt-method">
			<div>取卡地址：</div>
			<div style="flex: 1;">{{stallAddress}}</div>
		</div>
	</template>
	<!-- 自提 end -->
</panel>
<panel title="温馨提示">
    <p class="reminder"
       style="color:;
			font-size:0.42rem;
			line-height:0.6rem;
			font-weight:bold">
1、未满16周岁不能办理新卡入网。
<br>2、请在收到卡后30天内激活您的号卡，逾期未能激活的，本订单将自动取消，号卡失效。
<br>3、根据工信部要求，您的号卡激活且开通后将由人工对实名照片进行审核，审核不通过的将通过短信方式通知您按要求进行补上传照片操作，逾期若未补上传照片的，号码将被暂停通信服务。
<br>4、后续稽核证件不合格的会短信通知补充材料，如不按照要求补充材料，将在通知后5天内停机。    </p>
</panel><panel title="营销协议" v-show="protocols && protocols.length>0">
	<div class="argee-protocol" ref="argeeProtocol">
		<input type="checkbox" id="argeeProtocolCheck" v-model="argeeProtocol" @change="gsEvent('营销协议',argeeProtocol?'勾选同意营销协议':'取消勾选同意营销协议');"/>
		<label for="argeeProtocolCheck">我已阅读并同意</label> 
	</div>
	<div class="protocol" v-for="p in protocolList">
		<a @click="checkPdf(p);gsEvent('营销协议','查看营销协议【'+p.agreemrntName+'】');">
			{{ p.agreemrntName }}
		</a>
	</div>
	
	<!-- 协议弹窗 -->
	<div class="see-pdf" id="see-pdf" v-if="showProtocol"  style="position: fixed;">
		<div style="flex: 1;">
			<iframe style="width: 100%; height: 100%;border:none;" 
					:src="pdfUrl"></iframe>
		</div>
		<div class="pdf-close" style="text-align: center;line-height: 1.2rem;" @click="showProtocol=!showProtocol">
			关闭
		</div>
	</div>
	
</panel>
<div id="popup-confirm" @touchmove.prevent style="background-color: rgba(0,0,0,.7);
		position: fixed;width: 100%;height: 100%;
		z-index: 10000;top:0;padding: 0 0.7rem;
		display: flex;
    	flex-direction: column;
    	justify-content: center;" v-if="isConfirm">
	<panel title="订单提交信息确认" style="border-radius: 0.2rem;">
		
		
			<div class="input-item" style="align-items:flex-start">
				<div class="input-label" style="line-height: unset;flex: none;">
					<span>套餐信息</span>
				</div>
				<div class="input-content" style="font-size: 0.37rem;padding-left: 0.3rem;">
					<div style="font-weight:bold;">
								29元福利卡套餐
					</div>
				</div>
			</div>
		
		
			<div class="input-item" style="align-items:flex-start">
				<div class="input-label" style="line-height: unset;flex: none;">
					<span>订购号码</span>
				</div>
				<div class="input-content" style="font-size: 0.37rem;padding-left: 0.3rem;">
					{{orderInfo.number}}
				</div>
			</div>
		
			<div class="input-item" style="align-items:flex-start">
				<div class="input-label" style="line-height: unset;flex: none;">
					<span>客户姓名</span>
				</div>
				<div class="input-content" style="font-size: 0.37rem;padding-left: 0.3rem;">
					{{orderInfo.customerName}}
				</div>
			</div>
		
			<div class="input-item" style="align-items:flex-start">
				<div class="input-label" style="line-height: unset;flex: none;">
					<span>身份证号</span>
				</div>
				<div class="input-content" style="font-size: 0.37rem;padding-left: 0.3rem;">
						{{conceal(orderInfo.customerIdCard,6,11)}}
				</div>
			</div>
		
			<div class="input-item" style="align-items:flex-start">
				<div class="input-label" style="line-height: unset;flex: none;">
					<span>联系电话</span>
				</div>
				<div class="input-content" style="font-size: 0.37rem;padding-left: 0.3rem;">
					{{orderInfo.contactPhone}}
				</div>
			</div>
		

		
	
		<div style="color:#f00;font-weight:bold;font-size:0.4rem;">
			您已阅读业务服务协议及营销规则的相关内容并接受该条款。
		</div>
		<div style="font-weight:bold;font-size:0.4rem;">
			若您已知晓上述内容，请点击“确认”按钮
		</div>
		<div style="margin-top: 0.3rem;display: flex;height: 1rem;line-height: 1rem;border: 1px solid #ccc;border-radius: 0.2rem;font-size: 0.4rem;color: #ff0000;">
			<div style="flex: 1;text-align: center;border-right: 1px solid #ccc;" @click="isConfirm=false;gsEvent('提交订单，弹窗订单信息确认','点击取消按钮');">取消</div>
			<div style="flex: 1;text-align: center;color: #40affe;" @click="confirm();gsEvent('提交订单，弹窗订单信息确认','点击确认按钮');">确认</div>
		</div>
	</panel>
</div>			<div style="margin-top:1.37rem;"></div>
		</div>
		<transition name="fade">
			<div class="bottom-bar" v-show="priceLoaded" style="z-index:10;position: fixed;">
				<div class="off-sale-msg" v-if="saleStatus==0">
					抱歉，该商品已下架，暂时无法订购
				</div>
				<template v-else>
					<div v-if="totalAmount>0 && totalAmount!=='0'"  class="price-box">
						{{amountName}} ￥{{formatAmount(totalAmount,'0.00')}}
					</div>
				</template>
				<button class="button-submit" :class="{'disable':saleStatus == 0}" :disabled="saleStatus==0?'disabled':null" 
					@click="checkOrderInfo();gsEvent('提交订单','点击提交订单按钮');">提交订单</button>
			</div>
		</transition>
			<!--2019年7月10日 ，dyh无综资地址需走新建的，弹框二次提醒-->
		<div class="showCreateAdds" v-if="showZzAddress">
			<div class="box-content">
				<span class="ts">提示</span>
				<span class="tsCen">您输入的地址暂未查询到资源，可能暂时无法安装，请以10000号联系为准。</span>
				<div class="content-bot">
					<div class="buttonDiv">
						<button class="button primary"  @click="confirmAddress">确认</button>
						<button class="button edit" @click="addressEdit">返回修改</button>
					</div>
				</div>
			</div>
		</div>
		
	</div>
</body>
</html>	

<script type="text/javascript" src="https://fx.sh.189.cn/nxtmall/static/common/js/address_check.js"></script>
<script type="text/javascript" src="https://fx.sh.189.cn/nxtmall/static/common/js/numeral.min.js"></script>
<script type="text/javascript" src="https://fx.sh.189.cn/nxtmall/static/common/swiper-4.4.6/js/swiper.min.js"></script>
<script type="text/javascript" src="https://fx.sh.189.cn/nxtmall/static/common/datePicker/datePicker.js"></script>
<script type="text/javascript" src="https://fx.sh.189.cn/nxtmall/static/common/js/lodash.min.js"></script>
<script type="text/javascript" src="https://fx.sh.189.cn/nxtmall/static/common/js/vue.min.js"></script>
<script type="text/javascript" src="https://fx.sh.189.cn/nxtmall/static/common/js/layer_mobile/layer.js"></script>
<script type="text/javascript">

function showTip(msg,type,delay){
	var delay = delay | 3;
	var style='font-size:0.47rem;padding:0.3rem 0.5rem;';
	if(type==='error'){
		style = style + 'background-color:rgba(88,88,88,0.7);';
	}
	 layer.open({
		    content: msg,
		    skin: 'msg',
		    style:style,
		    time: delay 
	 });
};

var loadingId = null;

function showLoading(msg,style){
	style = style || 'font-size:0.33rem;white-space:nowrap;';
	loadingId = layer.open({
        type: 2,
        shadeClose:false,
        style:style,
        content:msg
    });
}

function closeLoading(){
	if(loadingId!==null){
		layer.close(loadingId);
		loadingId = null;
	}
}



var _disableScrollListenter = function(e){
	e.preventDefault();
}

var disablePageScroll = function(){
	document.body.addEventListener('touchmove', _disableScrollListenter, { passive: false });	
	document.body.addEventListener('mousewheel', _disableScrollListenter, { passive: false });		
}

var enablePageScroll = function(){
	document.body.removeEventListener('touchmove', _disableScrollListenter);	
	document.body.removeEventListener('mousewheel', _disableScrollListenter);		
}

/**
 * 自定义VUE组件
 */
//面板组件，面板用来包含一个模块，由标题和内容组成
Vue.component('panel', {
	  props: ['title','subTitle'],
	  template: `
		<div class="panel">
			<div class="panel-title-bar h-flex-box" v-if="title">
				<div class="panel-title-symbol"></div>
				<div class="panel-title" v-if="title">{{title}}</div>
				<div class="panel-sub-title" v-if="subTitle">{{subTitle}}</div>
			</div>
			<div class="panel-divide-line"></div>
			<div class="panel-content">
				<slot></slot>
			</div>
		</div>
	  `
});

	

	

	$(function(){
		var panels = $('.panel');
		console.log(panels);
		//定义VUE数据，固定的共用数据，可在此处定义
		var _data = {
			t:null,				//定时器对象
			showLoading:false,  //是否显示加载
			isSubmit:false,		//是否正在提交中
			orderInfo:{
				productId:'103857',	//宝贝ID
				productName:'企客团购（29元福利卡）',	//宝贝名称
				businessType: '300', //业务大类
				subBusinessType: '310',//业务小类
				acceptNumber:'SHCT_XTXT', //受理工号
				personnelId:'206295',
				deptId:'329',
				storeId:'12',
				sourceId:'265297',
				openId:'',
				deliveryMethod:'0', //配送方式，默认传0，传给统一后台可忽略配送方式
				amount:'',
				encryptSerialNumber:'', //加密下单流水号
				sourceChannelCode:'',  // 来源渠道编码
				salesNumber:'',   //促销工号
				salesNumber2:'LUCJ',   			//	促销工号2
				developingPerson2:'Y31000004358',			//集团小白第二发展人工号
			}, //订单信息
			amountName:'支付金额 ',  //费用显示名称
			priceLoaded:false,
			invalidField:'', //校验不通过的属性
			validatorErrMsg:'',//校验不通过的错误信息 
			saleStatus:'1', //商品上下架状态
			showZzAddress:false,//是否显示综资地址弹框
		};
		
		//定义VUE 属性观察
		var _watch = {
			'showLoading':function(nv,ov){
				if(nv){
					showLoading();				
				}else{
					closeLoading();
				}
			}	
		};
		
		//定义VUE 计算属性
		var _computed = {
				totalAmount:function(){
					var price = 0;
					if(this.selectedNumber && this.selectedNumber.prepay > 0 && this.selectedNumber.level >= 3){
						price += Number(this.selectedNumber.prepay); 
					}
					if(this.orderInfo.amount != ''){
						var amount = Number(this.orderInfo.amount) / 100;
						price += amount;
					}
					return price;
				}
		};
		
		//定义订单提交验证器
		var _validators = [];
		
		//订单提交前需要做的事
		var _preSubmits = [];
		
		//定义VUE方法，固定的共用方法，可在此处定义
		var _methods = {
			gsEvent:function(title,field){
				callGSEvent('企客团购（29元福利卡）',title,field);
			},
			formatAmount:function(amount,format){
				return numeral(amount).format(format);
			},
			conceal:function(str,start,num,symbol){
				return conceal(str,start,num,symbol);
			},
			//输入框点击时自动调整界面，防止输入法挡住输入框
			inputClick : function(e) {
 				var self = this;
				setTimeout(function() {
					e.target.scrollIntoViewIfNeeded();
					//e.target.scrollIntoView();
					//self.scrollTo(e.target);
				}, 500); 
			},
			//滚动到指定元素
			scrollTo : function(el) {
 				var top = $(el).offset().top;	//元素top
/*   				var content = $();	
				var st = content.scrollTop();	//滚动容器当前滚动位置top
				var ct = content.offset().top;	//滚动容器本身的top
				console.log(top,st,ct)
 */				$('html,body').animate({
					scrollTop : top - 20
				}, 500,function(){
					$(el).addClass('heartBeat');
				}); //定位 
			},
			setInvalidField:function(fieldName,scrollToElName,msg){
				var self = this;
				self.invalidField = fieldName;
				var el = self.$refs[scrollToElName];
				if(!el){
					if(msg){
						showTip(msg,'error',3);
					}
					return self.invalidField;
				}
				if(el.length && el[0].$el){
					el = el[0].$el;
				}
				var t = $(el).data('t');
				if(t){
					return self.invalidField;;
				}
				self.scrollTo(el);
				if(msg){
					showTip(msg,'error',3);
				}
				$(el).addClass('invalid-field');
 				t = setTimeout(function() {
					//self.invalidField = '';
					$(el).removeClass('heartBeat');
					$(el).removeClass('invalid-field');
					$(el).removeData('t');
				}, 3000);
 				$(el).data('t',t);
				return self.invalidField;
			},
			
			
			//返回修改地址
			addressEdit:function(){
				var self = this;
				self.showZzAddress = false;
				var el = self.$refs["enterAdd"];
				self.scrollTo(el);
			},
			
			//综资地址弹框确认按钮
			confirmAddress:function(){
				var self = this;
				self.showZzAddress = false;
				// 判断是否二次弹窗确认信息
				if(self.isShowConfirm){
					self.isConfirm = true;
				}else{
					self.submit();
				}
			},
			
			//校验订单
			checkOrderInfo:function(){
				var self = this;
				if(self.isSubmit){
					return;
				}
				if(self.validatorErrMsg){
					this.setInvalidField(this.invalidField,this.invalidField,this.validatorErrMsg);
					return;
				}
				for(var i=0,fn;fn=_validators[i++];){
					if((fn)(this)){
						return;
					}
				}
				if(self.orderInfo.createZzAddress){//如果需要创建地址
					self.showZzAddress = true;
					return;
				}
				// 判断是否二次弹窗确认信息 qxy 20190606 
				if(self.isShowConfirm){
					self.isConfirm = true;
				}else{
					self.submit();
				}
			},
			//提交订单
			submit:function(){
				var self = this;
				
				var orderInfo = $.extend({},self.orderInfo);
				orderInfo.orderOffers = self.orderOffers;
				
				//如果订单信息里的邮件地址为空，并且默认邮件地址不为空，则使用默认邮件地址
				if(!orderInfo.email && self.defaultEmail){
					orderInfo.email = self.defaultEmail;
				}
				//处理备注信息,判断是否有其他备注字段信息，有的话都拼接到备注字段中，以||分隔
				if(self.otherRemarkInfo){
					var remarkInfos = [];
					for(var i=0,field;field=self.otherRemarkFields[i];i++){
						var value = self.otherRemarkInfo[field];
						remarkInfos.push(field + ':' + value)
					}
					if(orderInfo.remark){
						remarkInfos.push(orderInfo.remark);
					}
					orderInfo.remark = remarkInfos.join('||');
				}
				// 处理备注信息，判断是否有其他选项字段信息，目前该字段用在饿了么 选择项目模块中使用
				if(self.otherSelectItemVal){
					var selectItems = [];
					if(orderInfo.remark){
						selectItems.push(orderInfo.remark);
					}
					selectItems.push(self.otherSelectItemVal);
					orderInfo.remark = selectItems.join('||');
				}
				
				// 2020-06-10 by qxy 新增特殊字符过滤
				var dataInfo = JSON.stringify(orderInfo);
				if(!filterFourByte(dataInfo)){
					alert('提交失败，订单信息存在无效字符');
					return;
				}
				
				console.log('提交订单信息');
				console.log(orderInfo);
				
				pushGSStep1({
					amount:orderInfo.amount,
					businessType: '300',
					productName:'企客团购（29元福利卡）',
					paymentMode:'月付',
					buyMode:''
				});
				
				pushGSStep2(orderInfo,orderInfo.orderOffers);
				
				pushGSStep3(orderInfo,self.protocols);
				self.isSubmit = true;
				self.showLoading = true;
				$.ajax({
			        type: 'POST',
			        url: '/nxtmall/order/saveOrder',
			        contentType: "application/json; charset=utf-8",
			        data: JSON.stringify(orderInfo),
			        dataType: "json",
			        headers: {
			        },
			        success: function (result) {
						self.showLoading = false;
						console.log(result);
						if(result.status==='success'){
						    pushGSStep4(result.data);
							// by qxy 2020-11-17 橙分期状态判断，如果状态为1 则跳转到橙分期支付页
							if(result.data.cfqStatus === 1){
								window.location.href = '/nxtmall/view/cfqOrderPay/' + result.data.orderNo;
							}else{
								if(result.data.amount){
									window.location.href = '/nxtmall/view/orderPay.html?orderNo=' + result.data.orderNo;
								}else{
									window.location.href = '/nxtmall/view/orderSuccess.html?orderNo=' + result.data.orderNo;
								}
							}
						}else{
							alert(result.message);
						}
						self.isSubmit = false;
			        },
			        error: function (message) {
						self.showLoading = false;
						console.log(message);
						alert("抱歉，请求失败了，可能是网络不好或者服务器太忙了，请换个网络环境或稍后再试一下吧");
						self.isSubmit = false;
			        }
			    });
				self.orderInfo.orderOffers = [];
			},
			//执行指定的订单信息校验
			doValidator:function(validatorName,field,callback,event){
				var self = this;
				var params = $.extend({validatorName:validatorName,event:event},self.orderInfo);
				self.showLoading = true;
				$.post('/nxtmall/businessRule/validator',params,
					function(result){
						self.showLoading = false;
						if(result.status!=='success'){
							alert(result.message);
							self.validatorErrMsg = result.message;
							if(field){
								self.invalidField = field;
							}
						}else{
							self.validatorErrMsg = '';
							if(callback){
								(callback)(result.data)
							}
						}
					}		
				).error(function(err){
					self.showLoading = false;
					console.log(err)
					alert("抱歉，请求失败了，可能是网络不好或者服务器太忙了，请换个网络环境或稍后再试一下吧");
				})
			}
		};
		
		//定义VUE created生命周期时间需要执行的方法列表
		var _created = []; 
		
		var _mounted = [];
		
_validators.push(function(vm){
});
_data.showProductDetailImgs = false;
_data.saleImg = '';
_data.staticResources = {"afterSales":"[]","content":[],"mainImgUrl":"","postageExplain":[],"problem":[],"saleId":"103857","thumbnail":""};
_data.saleImgs = [];

_data.payments = null;
//当前选中的付费周期
_data.payment = null;

_data.payCycleMap = {
		1:'年',
		2:'两年',
		3:'半年',
		4:'月'
};
//主商品列表
_data.mainOffers = []; 
//可选包分组
_data.offerGroups = [];
//不在分组中的可选包
_data.ungroupOffers = [];
//订单提交时需要提交的包列表
_data.orderOffers = [];
//付费周期对应的包
_data.paymentOffers = {};
//副卡包
_data.subNumberOffers = [];
//最大可加副卡数量
_data.maxSubNumberCount = 0;

//根据分组编号从可选包分组中查找指定编码的分组
_methods.findOfferGroupByGroupCode = function(groupCode){
	var self = this;
	for(var i=0;i<self.offerGroups.length;i++){
		if(self.offerGroups[i].groupCode === groupCode){
			return self.offerGroups[i];
		}
	}
	return null;
}

//解析可选包分组策略
_methods.parseGroupPolicy = function(policy){
	if(!policy){
		return {
			min:0,
			max:1,
			hideOffers:[],
	//		selectAll:true,
			subGroups:[{
				offerIds:[],
				showOffers:[],
				hideOffers:[]
			}]
		}
	}
	policy = policy.trim();
	var regxp = /^\((\w|\||\?|,|\(|\))*\)(\*|\+){1}\d{0,2}$/;
	if(!regxp.test(policy)){
		return null;
	}
	var regxp1 = /(\((\d|\||,)+\)(\?|\|)*)|(\d+(\?|\|))/g;    //切割策略分组的正则
	var regxp2 = /\d+/g;									//提取可选包编码的正则
	var regxp3 = /(\*|\+){1}(\d{0,1})/g;					//获取策略表达式最后2个字符的正则（比如：+,*,+2,*3）
	var result1 = policy.match(regxp1);
	var group = {
		min:0,
		max:1,
		selectAll:false,
		hideOffers:[],
		subGroups:[]
	}
	
	var ls = policy.match(regxp3);
	console.log(ls);
	var l = ls[0];

	var limitNum = 1;
	if(l.length>=2){
		var num = l.substring(1,2);
		console.log(num);
		limitNum = parseInt(num);
	}
	
	var c = result1[0].substring(result1[0].length-1);
	if(c=='|'){
		group.max = 1;
		if(l.indexOf('+')===0){
			group.min = 1;
		}
	}else if(c=='?'){
		group.max = result1.length;
		if(l.indexOf('+')===0){
			group.min = limitNum;
		}
	}
	
	for(var i=0;i<result1.length;i++){
		var re = result1[i];
		var subGroup = {
			offerIds : re.match(regxp2),
			showOffers:[],
			hideOffers:[]
		}
		if(subGroup.offerIds===undefined || subGroup.offerIds === null){
			subGroup.offerIds = [];
		}
		group.subGroups.push(subGroup);
	}
	console.log(group);
	return group;
}

//判断是否是和付费周期相关的包（年付包、两年付包）
_methods.isPaymentOffer = function(offer){
	var self = this;
	if(!self.payments || self.payments.length===0){
		return false;
	}
	for(var i=0;i<self.payments.length;i++){
		var payment = self.payments[i];
		if(offer.offerId == payment.paymentOfferId){
			return true;
		}
	}
	return false;
}

//处理加载出来的可选包数据
_methods.processSaleOffer = function(saleOfferData){
	var self = this;
	self.mainOffers = [];
	
	var offers = saleOfferData.offers;
	
	self.offerGroups = [];
	self.ungroupOffers = [];
	var protocolOfferIds = []; //查询营销协议使用的offerIds数组
	for(var i=0;i<offers.length;i++){
		var mainOffer = offers[i];
		// 主卡：10100002，副卡：20100002
		if(mainOffer.subRoleCode == '20100002' && mainOffer.offerBusType ==1){  //如果是副卡，先跳过 
			if(mainOffer.offerObjs){
				self.subNumberOffers = mainOffer.offerObjs; //副卡包
				self.maxSubNumberCount = self.subNumberOffers[0].maxNum; //副卡最大数量
			}
			continue;
		}
		protocolOfferIds.push(mainOffer.mainOfferId); //主商品加入offerIds,查询营销协议时使用
		mainOffer.selected = mainOffer.isSelect != '2';
		mainOffer.selectOffers = []; 		//选中的可选包
		if(mainOffer.offerObjs){
			mainOffer.offerObjs.forEach(function(oo){
				protocolOfferIds.push(oo.offerId); //可选包加入offerIds,查询营销协议时使用
				Vue.set(oo,'selected',false);
				Vue.set(oo,'type',"40");  //设置类型为可选包
				var num = 1;
				if(oo.minNum > 0){
					num = oo.minNum
				}
				Vue.set(oo,'num',num);
				
				//在可选包中放入可选包所属主商品的引用
				oo.mainOffer = mainOffer;
				
				if(oo.isSelect == 1){ //如果是必选包，直接放到已选择的包中
					mainOffer.selectOffers.push(oo);
					return true;
				}
				//如果是年付包或两年付包，将包放入付费周期包中
				if(self.isPaymentOffer(oo)){
					self.paymentOffers[oo.offerId] = oo;
					return true;
				}
				
				//如果有分组配置
				if(oo.groupCode){
/*					if(oo.groupCode=='100'){ //跳过副卡动作的包
						return true;
					}*/
					var og = self.findOfferGroupByGroupCode(oo.groupCode);
					if(!og){
						og = {
							groupCode:oo.groupCode, 
							groupName:oo.groupName,
							groupPolicy:oo.groupPolicy,
							selectCount:0 //当前选中的可选包数量
						}
						var parse = self.parseGroupPolicy(oo.groupPolicy);
						$.extend(og,parse);
						self.offerGroups.push(og);
					}
					var find = false;
					og.subGroups.forEach(function(sg){
						if(sg.offerIds.indexOf(oo.offerId)>=0){
							if(oo.isSHow == '1'){
								sg.showOffers.push(oo);
							}else{
								sg.hideOffers.push(oo);
							}
							find = true;
						}
					})
					if(!find){
						if(oo.isSHow!='1'){
							og.subGroups[0].hideOffers.push(oo);
						}else{
							og.subGroups[0].showOffers.push(oo);
						}
					}
				}else{ //没有配置分组
					if(oo.isSHow == '1'){ //如果包是可显示的
						self.ungroupOffers.push(oo);   //将包放入未分组可选包中
					}else{
						//mainOffer.selectOffers.push(oo);  //将包放入主商品的已选可选包中
					}
				}
			})
		}
		
		self.offerGroups.forEach(function(group){
			group.subGroups.forEach(function(sg){
				var offerIds = sg.offerIds;
				
				if(offerIds && offerIds.length>1){
					sg.showOffers.sort(function(v1,v2){
						return offerIds.indexOf(v1.offerId) - offerIds.indexOf(v2.offerId);
					})
				}
			})
		});
		self.mainOffers.push(mainOffer);
	}
	self.getSalesPrice();
	//营销协议
	if(self.getSalesProtocols){
		self.getSalesProtocols(protocolOfferIds);
	}
}

//改变可选包的数量
_methods.changeOfferNum = function(offer,num){
	var newNum = offer.num + num;
	if(newNum > offer.maxNum || newNum<1){
		return;
	}
	offer.num = newNum;
	this.getSalesPrice();
}

//获取费用
_methods.getSalesPrice = function(){
	var self = this;
	var offers = [];
	var offerGroups = self.offerGroups;
	for(var j=0;j<offerGroups.length;j++){
		var offerGroup = offerGroups[j];
		for(var k=0;k<offerGroup.subGroups.length;k++){
			var subGroup = offerGroup.subGroups[k];
			var find = false;
			subGroup.showOffers.forEach(function(so){
				if(so.selected){
					//将选中的可选包信息放入订单订购清单中
					offers.push({
						cpcpOfferId:so.offerId,
						userSelectOfferNum:so.num
					});
					find = true;
				}
			});
			if(find){
				subGroup.hideOffers.forEach(function(so){
					//将不显示的可选包放入订单订购清单中
					offers.push({
						cpcpOfferId:so.offerId,
						userSelectOfferNum:so.num
					})
				})
			}
		}
	}
	for(var i=0;i<self.mainOffers.length;i++){
		var mainOffer = self.mainOffers[i];
		if(mainOffer.selected){
			mainOffer.selectOffers.forEach(function(so){
				offers.push({
					cpcpOfferId:so.offerId,
					userSelectOfferNum:so.num
				});
			});
		}
	}
	for(var i=0;i<self.ungroupOffers.length;i++){
		var offer = self.ungroupOffers[i];
		if(offer.selected){
			offers.push({
				cpcpOfferId:offer.offerId,
				userSelectOfferNum:offer.num
			});
		}
	}
	if(offers.length===0){
		self.orderInfo.amount = 0;
		self.priceLoaded = true;
		return;
	}
	$.post('/nxtmall/product/getSalesPrice',
			{
				saleId:self.orderInfo.productId,
				jsonOffers:JSON.stringify(offers)
			},
			function(result){
				if(result.status==='success'){
					if(result.data && result.data.totalPrice){
						self.orderInfo.amount = result.data.totalPrice;
						self.amountName = result.data.priceAliasName?result.data.priceAliasName:(result.data.priceName?result.data.priceName:self.amountName);
						self.priceLoaded = true;
					}
				}
			}
	).error(function(err){
	})
}

_methods.getPaymentPriceName = function(payment){
	var self = this;
	if(payment){
		var price = self.formatAmount(payment.paymentSalePrice/100,'0.00');
		return payment.paymentSaleName;
		//return payment.paymentCycle + ":" + price
	}
	return '';
}

//点击分组中的可选包
_methods.clickGroupOffer = function(offer,group,subGroup){
	if(!group.selectAll){
		if(offer.selected){ //点击的可选包当前已经是选中状态的
			if(group.min ==1 && group.max == 1){
				return;
			}else {
				offer.selected = false;
				group.selectCount--;
			}
		}else{
			if(group.max == 1){
				group.subGroups.forEach(function(sg){
					sg.showOffers.forEach(function(o){
						o.selected = false;
					})
				});
				offer.selected = true;
				group.selectCount = 1;
			}else {
				var b = false;
				subGroup.showOffers.forEach(function(o){
					if(o.selected){
						b = true;
					}
					o.selected = false;
				});
				offer.selected = true;
				if(!b){
					group.selectCount ++;
				}
			}
		}
	}else {
		if(offer === 0){
			group.selectCount = 0;
		}else{
			group.selectCount = group.subGroups.length;
		}
		group.subGroups.forEach(function(sg){
			sg.showOffers.forEach(function(o){
				o.selected = offer>0;
			})
		});
	}
	this.getSalesPrice();
}

// 选择付费方式
_methods.selectPayment = function(payment){
	var self = this;
	if(self.payment === payment){
		return;
	}
	self.payment = payment;
}
// 获取宝贝对应包
_methods.getSaleOfferGroupBySaleId = function(){
	var self = this;
	// 根据宝贝ID 获取对应的包
	$.post('/nxtmall/product/getSaleOffer',
			{
				saleId:self.orderInfo.productId,
				paymentOfferId:''
			},
			function(result){
				if(result.status==='success'){
					console.log('-------');
					console.log(result);
					self.offerData = result.data;
					self.processSaleOffer(result.data);
					self.getSalesPrice();
				}else{
					alert('获取套餐包信息失败，' + result.message);
				}
			}
	).error(function(err){
		alert('获取套餐包信息失败，请稍后重试')
	})
}

_methods.initSwiper = function(){
	var self = this;
	// 轮播
	var swiper = new Swiper('.swiper-container', {
		pagination: {
			el: '.swiper-pagination',
			type: 'bullets',
		},
		autoplay: {
			delay: 3000,//3秒切换一次
			disableOnInteraction:false,
		},
		loop : true,
	});
	// 如果只有一个slide就销毁swiper
	if(swiper.slides && swiper.slides.length<4){
		swiper.destroy();
	}	
}

//将包添加到订单需要提交的包清单中
_methods.addOfferToOrderOffers = function(offer){
	this.orderOffers.push({
		offerId:offer.offerId,
		offerName:offer.offerName,
		num:offer.isSelect=='1'?offer.maxNum:offer.num, //必选的，以maxNum作为数量，可选的，以实际数量
		type:'40',
		deviceType:offer.offerBusType,
		isMain:offer.subRoleCode,
		additional:offer.islocaloffer,
	});	
}

//增加校验
_validators.push(function(vm){
	var self = vm;
	self.orderOffers = [];
	//是否组合商品
	var isSingleOffer = '2';
	var goodsType = '0';
	//组合商品才传组合商品的包
	if(isSingleOffer != '2' && goodsType != '1'){	// 2020-06-22 by qxy 新增判断，本地销售品没有组合产品包
		self.orderOffers.push({
			offerId:'100000149828780',
			offerName:'星卡流量版（29元）',
			num:1,
			type:'30' //30，组合商品
			//deviceType:self.mainOffers[0].offerBusType
		});
	}
	//拼接主商品
	for(var i=0;i<self.mainOffers.length;i++){
		var mainOffer = self.mainOffers[i];
		if(mainOffer.selected){
			//将主商品信息放入订单订购清单中
			self.orderOffers.push({
				offerId:mainOffer.mainOfferId,
				offerName:mainOffer.mainOfferName,
				num:1,
				type:'10',
				deviceType:mainOffer.offerBusType,
				isMain:mainOffer.subRoleCode,
				additional:mainOffer.islocaloffer, //是否本地可选包；1(默认):本地可选包，2：集团可选包
			});
			if(mainOffer.selectOffers){
				mainOffer.selectOffers.forEach(function(so){
					self.addOfferToOrderOffers(so);
				});
			}
		}
	}
	//拼接可选包
	var offerGroups = self.offerGroups;
	for(var j=0;j<offerGroups.length;j++){
		var offerGroup = offerGroups[j];
//		if(offerGroup.selectCount===0){
//			continue;
//		}
		if(offerGroup.selectCount<offerGroup.min){
			var id = 'group' + offerGroup.groupCode;
			console.log(id);
			return vm.setInvalidField(id,id,'至少要选择' + offerGroup.min + '个');
		}
		for(var k=0;k<offerGroup.subGroups.length;k++){
			var subGroup = offerGroup.subGroups[k];
			var hasShowOfferSelect = false;
			subGroup.showOffers.forEach(function(so){
				if(so.selected && so.mainOffer.selected){ //如果可选包和其所属主商品都是选中状态
					//将选中的可选包信息放入订单订购清单中
					self.addOfferToOrderOffers(so);
					hasShowOfferSelect = true;
				}
			});
			if(hasShowOfferSelect){ //如果子分组中有显示的可选包被选中，则将子分组中的所有隐藏可选包带上
				subGroup.hideOffers.forEach(function(ho){
					//将选中的可选包信息放入订单订购清单中
					self.addOfferToOrderOffers(ho);
				})
			}
		}
		//分组中的隐藏可选包都要带上
		offerGroup.hideOffers.forEach(function(so){
			//将不显示的可选包放入订单订购清单中
			self.addOfferToOrderOffers(so);
		})
	}
	//拼接不在分组中的可选包
	for(var i=0;i<self.ungroupOffers.length;i++){
		var offer = self.ungroupOffers[i];
		if(offer.selected){
			self.addOfferToOrderOffers(offer);
		}
	}	
	// 添加付费周期对应的可选包，年付包、两年付包等
	if(self.payment){
		var so = self.paymentOffers[self.payment.paymentOfferId];
		if(so){
			self.addOfferToOrderOffers(so);
		}
	}
	
});

_mounted.push(function(vm){
	//有付费周期，默认选中第一个
	if(vm.payments && vm.payments.length > 0){
		vm.selectPayment(vm.payments[0]);
	}
	vm.initSwiper();
		vm.getSaleOfferGroupBySaleId();
})

_created.push(function(vm){
	if(vm.staticResources){
		var content = vm.staticResources.content;
		var postageExplain = vm.staticResources.postageExplain;
		var afterSales = vm.staticResources.afterSales;
		var problem = vm.staticResources.problem;
		if(content){
			if(typeof content === 'string'){
				if(content.indexOf('\[\{\"src\"') == 0){
					var arr = JSON.parse(content);
					content = arr[0].src
				} 
				if(content.length>10){
					content = [{
						src:content
					}]
				}else{
					content = [];
				}
			}
			if(content.length>0){
				vm.saleImgs.push({'name':'宝贝详情','imgs':content});
			}
		}
		if(postageExplain){
			if(typeof postageExplain === 'string'){
				if(postageExplain.length>10){
					postageExplain = [{
						src:postageExplain
					}]
				}else{
					postageExplain = [];
				}
			}
			if(postageExplain.length>0){
				vm.saleImgs.push({'name':'资费说明','imgs':postageExplain});
			}
		}
		if(afterSales){
			if(typeof afterSales === 'string'){
				if(afterSales.length>10){
					afterSales = [{
						src:afterSales
					}]
				}else{
					afterSales = [];
				}
			}
			if(afterSales.length>0){
				vm.saleImgs.push({'name':'售后保障','imgs':afterSales});
			}
		}
		if(problem){
			if(typeof problem === 'string'){
				if(problem.length>10){
					problem = [{
						src:problem
					}]
				}else{
					problem = [];
				}
			}
			if(problem.length>0){
				vm.saleImgs.push({'name':'常见问题','imgs':problem});
			}
		}
	}
	if(vm.saleImgs.length>0){
		vm.saleImg = vm.saleImgs[0]
	}
	console.log('productInfo created');
})
	;
//增加组件需要的订单数据
_data.orderInfo.customerName = '';
_data.orderInfo.customerIdCard = '';
_data.orderInfo.contactPhone = '';

//用户已有号码数量
_data.usedNum = 5;

_watch['orderInfo.customerName'] = function(nv,ov){
	//如果联系人为空或者联系人和修改前的入网人相同，同步联系人=入网人
	if(!this.orderInfo.contactName || this.orderInfo.contactName==ov){
		this.orderInfo.contactName = nv;
	}
	this.checkCustomerInfo();
};

_watch['orderInfo.customerIdCard'] = function(nv,ov){
	this.checkCustomerInfo();
};

// by qxy 2020-06-04 清除上传照片
_methods.cleanImages = function(){
	var self = this;
	// 如果使用V4校验，当用户姓名或者身份证变化时，则清除orderInfo.msgId
	if(self.useV4){
		self.orderInfo.msgId = '';
	}
	for(k in self.images){
		self.images[k] = null;
	}
}

_methods.checkCustomerInfo = _.debounce(function(){
	this.cleanImages();
	
	//如果当前校验错误相关属性是身份证或者姓名，清空校验错误信息
	if(this.invalidField === 'customerIdCard' || this.invalidField==='customerName'){
		this.validatorErrMsg = '';
	}
	var self = this;
	if(this.orderInfo.customerName && regexp.idcard.test(this.orderInfo.customerIdCard)){
		//输入姓名身份证后，做本地下单黑名单校验（非CRM用户黑名单）、下单数量限制校验、入网人信息校验
		/**qxy 2019-10-10 新加终端校验规则 zzzdOrderStatusQueryValidator*/
		this.doValidator('zzzdOrderStatusQueryValidator,whiteListValidator,blackListValidator,orderCountValidator,customerInfoValidator,fiveKdValidator','customerIdCard',function(data){
			if(data.usedNum !== undefined){
				self.usedNum = data.usedNum;
			}
		},'customerInfo');
	}
},800);

//联系电话校验
_watch['orderInfo.contactPhone'] = function(nv,ov){
	this.checkContactPhone();
};
_methods.checkContactPhone = _.debounce(function(){
	if(this.invalidField === 'contactPhone'){
		this.validatorErrMsg = '';
	}
	var self = this;
	if(regexp.mobile.test(this.orderInfo.contactPhone)){
		this.doValidator('blackListValidator,whiteListValidator,orderCountValidator,suningPhoneActiveValidator','contactPhone',function(data){
		},'contactPhone');
	}
},800);

//增加校验
_validators.push(function(vm){
	var orderInfo = vm.orderInfo;
	if(!orderInfo.customerName){
		return vm.setInvalidField('customerName','customerName','请输入正确的用户名');
	}
	if(!regexp.idcard.test(orderInfo.customerIdCard)){
		return vm.setInvalidField('customerIdCard','customerIdCard','请输入正确的18位身份证号');
	}
	if(!regexp.mobile.test(orderInfo.contactPhone)){
		return vm.setInvalidField('contactPhone','contactPhone','请输入正确的联系电话');
	}
});

//增加Vue created中执行的方法
_created.push(function(vm){
	console.log('customerInfo created');
});/**
 * 上传证件信息模块相关
 */
;
//增加组件需要的订单数据
_data.otherImages = [];						// 临时存放其他证件照
_data.otherImageCount=0;
_data.useV4=true;	//是否使用V4
_data.minOtherImage=1;
_data.maxOtherImage=1;
_data.showOtherPanel = 'true';
_data.otherImageTips='上传工作证照片';	// 照片提示语
_data.otherImageTypes='realnameEmpCard';	// 照片类型
_data.imageTips = [];
_data.imageTypes = [];
	// 是否隐藏上传证件

_data.images = {
		// 身份证正面
			idCardFront:null,
		// 身份证反面
			idCardBack: null,
		// 免冠照
			frontFace:null,
		// 员工工作证件照
		// 经办人身份证正面
		// 经办人身份证反面
		// 经办人免冠照
		// 企业介绍信
		// 组织机构代码证
		// 三证合一/营业执照
		// 手持证件照
}
//判断是否显示上传身份证正面
_methods.isShowIdCardFront = function(){
	if(!this.useV4){
		return true;
	}
	if((this.orderInfo.customerName && regexp.idcard.test(this.orderInfo.customerIdCard))
			|| (this.orderInfo.operatorName && regexp.idcard.test(this.orderInfo.operatorIdCard))){
		return true;
	}
	return false;
}

// 添加其他证件照
_methods.addOtherImage = function(){
	var self = this
	var type = self.imageTypes[self.otherImages.length];
	var tips = self.imageTips[self.otherImages.length];
	var name = type+'-' + self.otherImageCount++;
	self.otherImages.push({
		name:name,
		remark:'',
		tips:tips
	});
	
	//如果显示其他照片上传面板
	if(self.showOtherPanel != 'false'){
		self.images[name] = null;
	}
},

// 删除当前其他证件照
_methods.delCurrentOtherImage = function(arr,item){
	removeArrayItem(arr,item);
	delete this.images[item.name];
},

_methods.checkCanUploadImage = function(type){
	var self = this;
	self.invalidField = '';
	if(!self.useV4){
		return self.invalidField;
	}
	if(type==='idCardFront'){
		if(self.orderInfo.customerName && regexp.idcard.test(self.orderInfo.customerIdCard)){
			return self.invalidField;
		}else{
			if(!self.orderInfo.customerName){
				return self.setInvalidField('customerName','customerName','请先输入姓名');
			}
			if(!self.orderInfo.customerIdCard){
				return self.setInvalidField('customerIdCard','customerIdCard','请先输入身份证');
			}
		}
	}else if(type==='idCardBack'){
		if(!self.images.idCardFront){
			return this.setInvalidField('idCardFront','idCardFront','请先上传身份证正面照');
		}
	}else if(type==='frontFace'){
		if(!self.images.idCardBack){
			return this.setInvalidField('idCardBack','idCardBack','请先上传身份证反面照');
		}
	}
	return self.invalidField;
}

// 上传证件 e,type,imgName
_methods.selectImage = function(e,type,imgName){
	var self = this
	if(self.checkCanUploadImage(type) != ''){
		return;
	}
	if(self[imgName]){
		return;
	}
	// 当使用V4流程，照片上传成功，则禁用当前照片
	if(self.useV4){
		if((imgName === 'idCardFront' || 
			imgName === 'idCardBack' ||
			imgName === 'frontFace') 
			&& self.images[imgName]){
			return;
		}
	}
	
	selectImage(function(){
		layer.open({
            type: 2,
            shadeClose:false,
            style:'font-size:0.37rem;white-space:nowrap',
            content: '正在上传并验证照片...'
        });
	},function(imgFile){
		var name = self.orderInfo.operatorName?self.orderInfo.operatorName:self.orderInfo.customerName;
		var idCard = self.orderInfo.operatorIdCard?self.orderInfo.operatorIdCard:self.orderInfo.customerIdCard;
		self.uploadOrderImage(
			{
				name:name,
   				idCard:idCard,
   				type:type,
   				msgId:self.orderInfo.msgId,
   				imgFile:imgFile,
   				onSuccess:function(msgId){
              		layer.closeAll();
           			console.log(msgId);
           			self.orderInfo.msgId = msgId;

                    self.images[imgName] = getObjectURL(imgFile);
                    // 其他照片
                    self.otherImages.forEach(function(item,index){
                    	if(item.name === imgName){
                    		self.$set(item,'id',index)
                    	}
                    })
   				},
   				onFail:function(msg){
   					self.images[imgName] = null;
           			layer.closeAll();
           			alert(msg);
   				}
			}
		)
	},0)
},

// 上传证件方法
_methods.uploadOrderImage = function(params){
	function appendValue(form,field,value){
		if(null===value || undefined===value || ''===value){
			return;
		}
		form.append(field,value);
	}
	if(!params || !params.imgFile){
		return;
	}
	var formData = new FormData();
	appendValue(formData,'deviceNumber',params.deviceNumber);
	appendValue(formData,'name', params.name);
	appendValue(formData,'idCard', params.idCard);
	appendValue(formData,'type', params.type);
	appendValue(formData,'msgId', params.msgId);
	appendValue(formData,'file', params.imgFile);
	// 判断是否使用V4
		appendValue(formData,'useV4', 'yes');
    $.ajax({
        url: '/nxtmall/orderImage/upload',
        type: 'POST',
        processData: false,
        contentType: false,
        data: formData,
        success: function(result) {
        	if(result.status=='success'){
        		if(params.onSuccess){
        			(params.onSuccess)(result.data);
        		}
        	}else{
        		if(params.onFail){
        			(params.onFail)(result.message);
        		}
        	}
        },
        error:function(xhr,errMsg,t){
        	if(params.onFail){
        		(params.onFail)('请求失败')
        	}
        }
     });
}

//增加校验
_validators.push(function(vm){
	var imges = vm.images;
	if(imges){
		var imgs = [];
		for(key in imges){
			
			if(key === 'empCard'){
				if(imges[key] === null){
					return vm.setInvalidField(key,key,'请上传照片');
				}
			}
			
			if(key === 'idCardFront'){
				if(imges[key] === null){
					return vm.setInvalidField(key,key,'请上传身份证正面照');
				}
			}
			
			if(key === 'idCardBack'){
				if(imges[key] === null){
					return vm.setInvalidField(key,key,'请上传身份证反面');
				}
			}
			
			if(key === 'frontFace'){
				if(imges[key] === null){
					return vm.setInvalidField(key,key,'请上传免冠照');
				}
			}
			
			if(key === 'agentIdCardFront'){
				if(imges[key] === null){
					return vm.setInvalidField(key,key,'请上传经办人身份证正面照');
				}
			}
			
			if(key === 'agentIdCardBack'){
				if(imges[key] === null){
					return vm.setInvalidField(key,key,'请上传经办人身份证反面');
				}
			}
			
			if(key === 'agentFrontFace'){
				if(imges[key] === null){
					return vm.setInvalidField(key,key,'请上传经办人免冠照');
				}
			}
			
			if(key === 'introduction'){
				if(imges[key] === null){
					return vm.setInvalidField(key,key,'请上传企业介绍信');
				}
			}
			
			if(key === 'organization'){
				if(imges[key] === null){
					return vm.setInvalidField(key,key,'请上传组织机构代码证');
				}
			}
			
			if(key === 'businessLicense'){
				if(imges[key] === null){
					return vm.setInvalidField(key,key,'请上传营业执照/三证合一证件');
				}
			}
			
			// 其他照片
			if(key.indexOf('-') != -1){
				if(imges[key] === null){
					return vm.setInvalidField(key,key,'请上传其他证件照');
				}
			}
			
			// 存放已上传的照片类型信息
			imgs.push(key);
		}
		vm.orderInfo.images = imgs.join(',');
	}
})


//增加Vue created中执行的方法
_created.push(function(vm){
	
	var tips = "上传其他照片";
	var type = "otherImage";
	if(!vm.otherImageTips){
		vm.imageTips = [tips];
	}else{
		vm.imageTips = vm.otherImageTips.split(",");
	}
	if(!vm.otherImageTypes){
		vm.imageTypes = [type];
	}else{
		vm.imageTypes = vm.otherImageTypes.split(",");
	}
	if(vm.imageTips.length>0 && vm.imageTips[vm.imageTips.length - 1] != ''){
		tips = vm.imageTips[vm.imageTips.length - 1];
	}
	if(vm.imageTypes.length>0 && vm.imageTypes[vm.imageTypes.length - 1] != ''){
		type = vm.imageTypes[vm.imageTypes.length - 1];
	}
	for(var i=0;i<vm.maxOtherImage;i++){
		if(i>=vm.imageTips.length){
			vm.imageTips.push(tips);
		}
		if(i>=vm.imageTypes.length){
			vm.imageTypes.push(type);
		}
	}
	if(vm.minOtherImage>0){
		for(var i=0;i<vm.minOtherImage;i++){
			vm.addOtherImage();
		}
	}
	console.log('uploadCertificate created')
});

$('#popup-number-select').appendTo('.main-container');

_data.orderInfo.number = '';
_data.showNumberSelect = false;
_data.numbers = [];
_data.hasNextNumberPage = true;
_data.queryNumberParams = {
	personnelId:'206295',
	productId:'103857',
	source:'e7ee17ae71144391bf48c20b8b6f8ccc',
	inNum:'',
	numSection:'',
	numberLevel:'0',
	page:1,
	pageSize:10
};
_data.selectNumber = null;
_data.selectedNumber = null;
_data.agreeNumber = false;

//选中的副卡
_data.subNumbers = [];
//当前选择号码的类型，main：主卡,sub:副卡
_data.currentSelectNumberType = 'main';
//当前选择的副卡序号
_data.currentSubNumberIndex = 0;

// 特殊设置
_data.autoNumberSelect = false;
_data.defaultNumberSelect = false;

_methods.prevNumberPage = function(){
	if(this.queryNumberParams.page>1){
		this.queryNumberParams.page--;
		this.loadNumbers();
	}
};

_methods.nextNumberPage = function(){
	if(this.queryNumberParams.page<20){
		this.queryNumberParams.page++;
		this.loadNumbers();
	}
};


_methods.clickSelectNumberButton = function(type,subNumberIndex){
	var self = this;
//	var top = window.pageYOffset;
//	$('#popup-number-select').css('top',top+'px');
//	disablePageScroll();
	self.showNumberSelect=true;
	self.currentSelectNumberType = type;
	self.currentSubNumberIndex = subNumberIndex;
	self.loadNumbers();
}

_methods.addSubNumber = function(){
	this.subNumbers.push({
		number:'',
		offers:[]
	})
}

_methods.removeSubNumber = function(index){
	var number = this.subNumbers[index].number;
	this.subNumbers.splice(index,1);
	//删除的副卡如果已经选过号，需要调用后台请求，删除选中的号码
	if(number){
		// 同时将后端session中清除
		$.post('/nxtmall/number/removeSubNumber',{index:index},function(result){
			if(result.status==='success'){
				console.log('=-=-=-=-==')
			}else{
				alert(result.message);
			}
		}).error(function(err){
			console.log(err);
			alert("抱歉，请求失败了，可能是网络不好或者服务器太忙了，请换个网络环境或稍后再试一下吧");
		})
	}
}

_methods.clickNumber = function(numberItem){
	if(this.checkNumberUsed(numberItem.number)){
		return;
	}
	this.selectNumber = numberItem;
}

//检查指定号码是否已经选中
_methods.checkNumberUsed = function(number){
	if(this.orderInfo.number === number){
		return true;
	}
	if(this.subNumbers){
		for(var i=0;i<this.subNumbers.length;i++){
			if(this.subNumbers[i].number === number){
				return true;
			}
		}
	}
	return false;
}

//加载号码
_methods.loadNumbers = function(){
	var self = this;
	if(self.queryNumberParams.page<20){
		self.showLoading = true;
		var url = '/nxtmall/number/query';
		if(self.currentSelectNumberType==='sub'){
			url = '/nxtmall/number/querySubNumbers';
		}
		self.queryNumberParams.numSection = '';
		$.post(url,self.queryNumberParams,
			function(result){
				self.showLoading = false;
				if(result.status==='success'){
					// 判断是否为系统分配号码
					if(self.autoNumberSelect){
						if(result.data){
							self.orderInfo.number = result.data[0].number;
							self.selectNumber = result.data[0];
							self.selectNumberOk();
						}
					}else if(self.defaultNumberSelect){
						self.numbers = result.data;
						// 默认随机选中一个
						if(self.numbers){
							var num = randomNumber(1,self.numbers.length);
							self.orderInfo.number = self.numbers[num].number;
							self.selectNumber = self.numbers[num];
							self.selectNumberDefault();
						}
						self.hasNextNumberPage = self.numbers.length==self.queryNumberParams.pageSize;
						if(self.orderInfo.number){
							for(var i=0;i<self.numbers.length;i++){
								if(self.numbers[i].number === self.orderInfo.number){
									self.selectNumber = self.numbers[i];
									return;
								}
							}
						}
					}else{
						self.numbers = result.data;
						self.hasNextNumberPage = self.numbers.length==self.queryNumberParams.pageSize;
						self.selectNumber = null;
						if(self.orderInfo.number){
							for(var i=0;i<self.numbers.length;i++){
								if(self.currentSelectNumberType === 'main'){
									if(self.numbers[i].number === self.orderInfo.number){
										self.selectNumber = self.numbers[i];
										return;
									}
								}else{
									if(self.numbers[i].number === self.subNumbers[self.currentSubNumberIndex].number){
										self.selectNumber = self.numbers[i];
										return;
									}
								}
							}
						}
					}
				}else{
					alert(result.message);
				}
			}
		).error(function(){
			self.showLoading = false;
		});
	}
};

//默认选择第一个号码
_methods.selectNumberDefault = function(){
	var self = this;
	if(!self.selectNumber){
		alert('请先选择一个号码');
		return;
	}
	self.showLoading = true;
	$.post('/nxtmall/number/select',{number:self.selectNumber.number},
		function(result){
			if(result.status==='success'){
				self.orderInfo.number = self.selectNumber.number;
			}else{
				alert(result.message);
			}	
			self.showLoading = false;
		}
	).error(function(){
		self.showLoading = false;
	});
};

//确定选择号码
_methods.selectNumberOk = function(){
	var self = this;
	if(!self.selectNumber){
		alert('请先选择一个号码');
		return;
	}
	self.showLoading = true;
	var url = '/nxtmall/number/select';
	var params = {number:self.selectNumber.number};
	if(self.currentSelectNumberType==='sub'){
		url = '/nxtmall/number/selectSubNumber';
		params = {number:self.selectNumber.number,index:self.currentSubNumberIndex};
	}
	$.post(url,params,
		function(result){
			if(result.status==='success'){
				if(self.currentSelectNumberType==='main'){
					self.orderInfo.number = self.selectNumber.number;
					self.selectedNumber = self.selectNumber;
				}else{
					var offers = [];
					//拼装副卡包
					self.subNumberOffers.forEach(function(o){
						offers.push({
							numFromFlag:'01',
							offerId:o.offerId,
							offerName:o.offerName,
							isMain:o.subRoleCode,
							type:'40',
							deviceType:'1000001315',
							deviceNumber:self.selectNumber.number,
							actType:'ADD',
							numOperationType:'ADD',
							attrType:'K'
						})
					});
					var subNumber = {
						number:self.selectNumber.number,
						offers:offers
					};
					self.subNumbers[self.currentSubNumberIndex] = subNumber;
				}
				self.showNumberSelect = false;
				self.selectNumber = null;
				//enablePageScroll();					
			}else{
				alert(result.message);
			}	
			self.showLoading = false;
		}
	).error(function(){
		self.showLoading = false;
	});
};

// 搜索号码
_methods.numSearch = function(){
	var self = this;
	self.queryNumberParams.page = 1;
	self.loadNumbers();
};

//取消选择号码
_methods.selectNumberCancel = function(){
	this.showNumberSelect = false;
	this.queryNumberParams.numType = '';
//	enablePageScroll();						
};

// iccid 校验
_watch['orderInfo.iccid'] = function(nv,ov){
	var self = this;
	self.validatorErrMsg = ''
	if(nv && nv.length ===19 ){
		self.queryIccidWhiteList();
	}
}
_methods.queryIccidWhiteList = _.debounce(function(){
	var self = this;
	self.doValidator('iccidWhiteListValidator','iccid',function(result){
		console.log('---------')
		console.log(result)
	})
},1000);

//计算最大可装副卡数量
_computed.calcMaxSubNumberCount = function(){
	var self = this;
	if(!self.subNumberOffers){
		return 0;
	}
	var n1 = 4-self.usedNum;
	return 0;
	// return self.maxSubNumberCount>n1?n1:self.maxSubNumberCount;
}

_validators.push(function(vm){
	var orderInfo = vm.orderInfo;
	if(!orderInfo.number){
		return vm.setInvalidField('number','number','请选择号码');
	}
	if(vm.selectedNumber && vm.selectedNumber.minAmount>0 && !vm.agreeNumber){
		return vm.setInvalidField('agreeNumber','agreeNumber','请先阅读并同意号码消费规则');
	}
	
	// 拼接副卡可选包
	if(vm.subNumbers){
		for(var i=1;i<4;i++){
			delete orderInfo['subNumber'+i];
		}
		for(var i=0;i<vm.subNumbers.length;i++){
			if(!vm.subNumbers[i].number){
				return vm.setInvalidField('subNumber'+i,'subNumber'+i,'请选择副卡号码');
			}
			if(vm.subNumbers[i].offers){
				vm.subNumbers[i].offers.forEach(function(o){
					vm.orderOffers.push(o);
				})
			}
			// 将副卡号码放到订单信息中
			var subNumber = 'subNumber'+(i+1);
			vm.$set(orderInfo,subNumber,vm.subNumbers[i].number);
		}
	}
	
	// 判断商品是否配置了ICCID
});

_created.push(function(vm){
	// 判断是否设置了随机自动选中一个号码标志
	if(vm.autoNumberSelect){
		vm.queryNumberParams.flag = 'autoNumberSelect';
		vm.loadNumbers();
	}else if(vm.defaultNumberSelect){
		vm.queryNumberParams.flag = 'defaultNumberSelect';
		vm.loadNumbers();
	}
	
});;

_data.selectProvince = '';
_data.selectCity = '';
_data.selectArea = '';
_data.address = '';
//_data.orderInfo.contactName = '';
_data.orderInfo.address = '';
_data.orderInfo.provinceCode = '';
_data.orderInfo.cityCode = '';
_data.orderInfo.areaCode = '';
_data.orderInfo.deliveryMethod = '1';	// 1：配送，2自提，AG:代理商配送
_data.allProvinces=[];
_data.allCitys = [];
_data.allAreas = [];
_data.stallAddress = '';

// 2020-07-23 by qxy  安装地址是否同配送地址（注：目前使用场景有 集团小白套餐）
_data.isInstAsPs = 'false';

_data.showPanel = true;
_data.showAddress = false;

//qxy 外省配送需要此信息 2019-0509
_data.orderInfo.fSendProvince = '';
_data.orderInfo.fSendCity = '';


_methods.loadProvinces = function(){
	var self = this;
	$.post('/nxtmall/province/getAllProvince',{},
		function(result){
			if(result.status==='success'){
				var provinces = result.data;
				var deliveryArea = 'SH';
				var useProvinces = [];
				//配送区域如果为上海的，过滤返回的省市信息，只保留上海市
				if(deliveryArea === 'SH'){
					for(var i=0;i<provinces.length;i++){
						if(provinces[i].name === '上海市'){
							useProvinces.push(provinces[i]);
							break;
						}
					}
				}else if(deliveryArea === 'ALL'){
					useProvinces = provinces;
				}else{
					var provinceArr=deliveryArea.split(",");
					for(let i in provinceArr){
						for(let j in provinces){
							if(provinceArr[i]===provinces[j].name){
								useProvinces.push(provinces[j]);
							}
						}
					}
				}
				self.allProvinces = useProvinces;
				if(self.allProvinces.length === 1){
					self.selectProvince = self.allProvinces[0];
				}
			}
		}
	)
}

_methods.loadProvinceCitys = function(province){
	var self = this;
	if(province.citys!==null && province.citys!==undefined){
		self.allCitys = province.citys;
		if(self.allCitys.length === 1){
			self.selectCity = self.allCitys[0];
		}
		return
	}
	province.citys = [];
	$.post('/nxtmall/province/getCityListByProvinceCode',{pcode:province.code},
		function(result){
			if(result.status==='success'){
				province.citys = result.data;
				self.allCitys = province.citys;
				if(self.allCitys.length === 1){
					self.selectCity = self.allCitys[0];
				}
			}
		}
	)
}

_methods.loadCityAreas = function(city){
	var self = this;
	if(city.areas!==null && city.areas!==undefined){
		self.allAreas = city.areas;
		return
	}
	city.areas = [];
	$.post('/nxtmall/province/getAreaListByCityCode',{ccode:city.code},
		function(result){
			if(result.status==='success'){
				city.areas = result.data;
				self.allAreas = city.areas;
			}
		}
	)
}

_methods.checkAddress = _.debounce(function(){
	if(this.address){
		if(isAddressContainsProvinceCity(this.address)){
			this.setInvalidField('address','address','您输入的地址不符合规范，请重新输入');
		}
	}
},800);

_watch.address = function(nv,ov){
	this.checkAddress();
}

_watch.selectProvince = function(nv,ov){
	this.selectCity = '';
	this.selectArea = '';
	this.allCitys = [];
	this.allAreas = [];
	if(nv){
		this.loadProvinceCitys(nv);
	}
}

_watch.selectCity = function(nv,ov){
	this.selectArea = '';
	this.allAreas = [];
	if(nv){
		this.loadCityAreas(nv);
	}
}

// 选择配送方式
_methods.checkMethod = function(v){
	var self = this;
	if(v===1){
		self.orderInfo.fSendProvince = '';
		self.orderInfo.fSendCity = '';
		self.orderInfo.address = '';
	}
	if(v===2){	
		self.orderInfo.provinceCode = '';
		self.orderInfo.cityCode = '';
		self.orderInfo.areaCode = '';
	    self.orderInfo.fSendProvince = "上海市";
		self.orderInfo.fSendCity = "上海市";
		self.orderInfo.address = '青浦区商城街55号';
	}
	self.orderInfo.deliveryMethod = v;
}

_validators.push(function(vm){
	// 配送
	if(vm.orderInfo.deliveryMethod === '1' || vm.orderInfo.deliveryMethod === 'AG' || vm.showAddress){
		if(!vm.selectProvince){
			return vm.setInvalidField('province','province','请选择所在省');
		}
		if(!vm.selectCity){
			return vm.setInvalidField('city','city','请选择所在市');
		}
		if(!vm.selectArea){
			return vm.setInvalidField('area','area','请选择所在区县');
		}
		if(!vm.address){
			return vm.setInvalidField('address','address','请输入详细地址');
		}
		if(vm.address){
			if(isAddressContainsProvinceCity(vm.address)){
				return vm.setInvalidField('address','address','您输入的地址不符合规范，请重新输入');
			}
		}
		/*if(!vm.orderInfo.contactName){
			return vm.setInvalidField('contactName','contactName','请输入收货人姓名');
		}*/
		vm.orderInfo.provinceCode = vm.selectProvince.code;
		vm.orderInfo.cityCode = vm.selectCity.code;
		vm.orderInfo.areaCode = vm.selectArea.code;
		vm.orderInfo.address = vm.selectProvince.name;
		vm.orderInfo.fSendProvince = vm.selectProvince.name;
		vm.orderInfo.fSendCity = vm.selectCity.name;
		if(vm.selectCity.name !== vm.selectProvince.name){
			vm.orderInfo.address += vm.selectCity.name;
		}
		vm.orderInfo.address += (vm.selectArea.name + vm.address);
		
		// 2020-07-23 by qxy 判断是否配置了安装地址同配送地址
		if(vm.isInstAsPs == 'true'){
			// 将配送地址赋值给安装地址
			vm.orderInfo.installAddress = vm.orderInfo.address
		}
	}
});

_created.push(function(vm){
	console.log('deliveryInfo created');
	vm.loadProvinces();
	
	// 如果配置了代理商配送，则忽略其他方式
			// 没有配送，没有自提，自提地址不为空情况下，则为自提，面板隐藏
			// 或者有自提，没有配送
			vm.showPanel = false;
			vm.orderInfo.deliveryMethod = '2';
			vm.orderInfo.fSendProvince = "上海市";
			vm.orderInfo.fSendCity = "上海市";
			vm.orderInfo.address = '青浦区商城街55号';
			vm.stallAddress = '青浦区商城街55号';
	
	var urlParams = getUrlParams(window.location.href);
	console.log(urlParams);
	if(urlParams.stall=='1'){
		vm.orderInfo.deliveryMethod = '2';
		vm.orderInfo.fSendProvince = "上海市";
		vm.orderInfo.fSendCity = "上海市";
		if(urlParams.stallAddress){
			vm.orderInfo.address = urlParams.stallAddress;
			vm.stallAddress = urlParams.stallAddress;
		}else{
			vm.stallAddress = '青浦区商城街55号';
		}
		vm.showPanel = true;
	}else if(urlParams.stall=='2'){
		vm.orderInfo.deliveryMethod = 'AG';
		vm.showPanel = true;
	}
	
	
});/**
 * 账单地址模块相关
 */

;

//增加组件需要的订单数据
_data.orderInfo.billAddress = '';
_data.orderInfo.email = '';
_data.defaultEmail = ''; //默认电子邮箱

// 参数校验
_validators.push(function(vm){
	var orderInfo = vm.orderInfo;
	
	
		if(orderInfo.number){
			vm.defaultEmail = orderInfo.number+'@189.cn';
		}else if(orderInfo.contactPhone){
			vm.defaultEmail = orderInfo.contactPhone+'@189.cn';
		}
})
;; 
_data.argeeProtocol = false;
_data.showProtocol = false;
_data.pdfUrl = '';
_data.protocols = [];
_data.fixedOfferIds = [];
_data.removeOfferIds = [];
//增加 隐藏指定协议功能



$('#see-pdf').appendTo('.main-container');

_computed.protocolList = function(){
	return _.uniqWith(this.protocols, function(p1,p2){
		return p1.agreementUrl === p2.agreementUrl;
	})
}

_methods.getSalesProtocols = function(offerIds){
	var self = this;
	if(offerIds==null || offerIds===undefined){
		offerIds = [];
	}
	//如果配置了固定协议的offerId，合并到offerIds中去
	if(self.fixedOfferIds.length>0){
		offerIds = offerIds.concat(self.fixedOfferIds)
	}
	
	//剔除 需要隐藏协议的offerId
	if(self.removeOfferIds.length>0){
		for(var i=0;i<self.removeOfferIds.length;i++){
			removeArrayItem(offerIds,self.removeOfferIds[i]);
		}
	}
	
	var find = false;
	self.orderInfo.offerIds = '';
	if(offerIds){
		// 2020-08-11 将ids存放到order中，带到后端
		self.orderInfo.offerIds = offerIds.join(',');
		
		$.post('/nxtmall/product/getOfferAgreement',
				{
					offerIds:offerIds.join(',')
				},
				function(result){
					console.log(result);
					var urls = {};
					if(result.status==='success'){
						self.protocols = [];
						result.data.forEach(function(o){
							if(!urls[o.agreementUrl]){
								self.protocols.push(o);
								urls[o.agreementUrl] = true;
							}
							if(o.agreemrntName==='业务服务协议'){
								find = true;
							}
						})
						if(!find && BASE_PROTOCOL){
							//加入固定的业务服务协议
							self.protocols = self.protocols.concat(BASE_PROTOCOL);
						}
						self.protocols.sort(function(v1,v2){
							if(v1.agreementUrl>v2.agreementUrl){
								return -1;
							}else if(v2.agreementUrl>v1.agreementUrl){
								return 1;
							}
							return 0;
						});
					}
				}
		).error(function(err){
		})
	}else {
		if(BASE_PROTOCOL){
			//加入固定的业务服务协议
			self.protocols = self.protocols.concat(BASE_PROTOCOL);
		}
	}
}

_methods.convertPdfUrl = function(url){
	return convertProtocolPdfUrl(url); //调用common.js里的转换协议pdf方法
}

_methods.checkPdf = function(item){
	var self = this;
	var useDfsPdf = '';
	if(useDfsPdf === '1' && item.dfsUrl){
		window.open('/nxtmall/common/getProtocolPdf?pdfUrl=' + item.dfsUrl);
	}else{
		self.showProtocol = true;
		self.pdfUrl = self.convertPdfUrl(item.agreementUrl);
	}
}

_validators.push(function(vm){
	if(!vm.argeeProtocol){
		return vm.setInvalidField('argeeProtocol','argeeProtocol','请先阅读并同意协议');
	}
});

_created.push(function(vm){
	if(vm.mainOffers === undefined || vm.mainOffers ===null || vm.mainOffers.length==0){
		vm.getSalesProtocols();
	}
});

_mounted.push(function(vm){
	
});/**
 * 	提交信息二次确认框模块
 */
;
;

$('#popup-confirm').appendTo('.main-container');

_data.isConfirm = false; // 弹窗控制
_data.isShowConfirm = true; // 后台设置是否显示二次确认框

// 确认
_methods.confirm = function(){
	var self = this;
	self.isConfirm = false;
	self.$nextTick(function(){
		self.submit();  // 提交订单
	},100)
};

_created.push(function(vm){
	console.log('confirm created');
});;

//增加组件需要的订单数据
if(_data.otherRemarkInfo === undefined || _data.otherRemarkInfo === null){
	_data.otherRemarkInfo = {};
	//其他备注字段 字段名数组，后续拼装时为保证顺序，按数组中顺序拼装
	_data.otherRemarkFields = [];
}
//
_data.otherRemarkFields.push('公司名称');

	_validators.push(function(vm){
		var required = 'true';
		var fieldName = 'otherRemarkInfo_公司名称';
		var elName = 'otherRemarkInfo_公司名称';
		
		// 添加url参数加密判断
		var value = '';
			value = '上海韵达货运有限公司';
		
		if(required == 'true'){
			var msg = "[公司名称]参数为空";
			if(value==='' || value===undefined || value===null){
				return vm.setInvalidField(fieldName,elName,msg);
			}
		}
		
		_data.otherRemarkInfo['公司名称'] = value;
	});

//增加Vue created中执行的方法
_created.push(function(vm){
	console.log('otherRemarkInfo_公司名称 created');
});;

//增加组件需要的订单数据
if(_data.otherRemarkInfo === undefined || _data.otherRemarkInfo === null){
	_data.otherRemarkInfo = {};
	//其他备注字段 字段名数组，后续拼装时为保证顺序，按数组中顺序拼装
	_data.otherRemarkFields = [];
}
//
_data.otherRemarkFields.push('自提地址');

	_validators.push(function(vm){
		var required = 'true';
		var fieldName = 'otherRemarkInfo_自提地址';
		var elName = 'otherRemarkInfo_自提地址';
		
		// 添加url参数加密判断
		var value = '';
			value = '上海市青浦区胜利路204弄1号101';
		
		if(required == 'true'){
			var msg = "[自提地址]参数为空";
			if(value==='' || value===undefined || value===null){
				return vm.setInvalidField(fieldName,elName,msg);
			}
		}
		
		_data.otherRemarkInfo['自提地址'] = value;
	});

//增加Vue created中执行的方法
_created.push(function(vm){
	console.log('otherRemarkInfo_自提地址 created');
});
		
		new Vue({
			el:'.main-container',
			data:_data,
			watch:_watch,
			computed:_computed,
			methods:_methods,
			created:function(){
				for(var i=0,fn;fn=_created[i++];){
					(fn)(this);
				}
				var goodsType = '0';
				if(goodsType == '1'){
					this.priceLoaded = true;
					// by qxy 2020-05-09 直接取商品中的价格
					this.orderInfo.amount = '0.00';
					this.saleStatus = 1;
				}
			},
			mounted:function(){
				if(/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)){
					$('.content').find('input').on('blur',function(){
						window.scrollTo(0,window.scrollY);
					})
				}
				
				for(var i=0,fn;fn=_mounted[i++];){
					(fn)(this);
				}
				
 				$('.panel').first().addClass('panel-top-round-corner');
				$('.panel').last().addClass('panel-bottom-round-corner'); 
				
			}
		})
	})
	

</script>
